File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 4141int foc_mq_handle (mqd_t mq , FAR struct foc_mq_s * h )
4242{
4343 int ret = OK ;
44- uint8_t buffer [5 ];
44+ uint8_t buffer [CONTROL_MQ_MSGSIZE ];
4545
4646 /* Get data from AUX */
4747
48- ret = mq_receive (mq , (char * )buffer , 5 , 0 );
48+ ret = mq_receive (mq , (char * )buffer , CONTROL_MQ_MSGSIZE , 0 );
4949 if (ret < 0 )
5050 {
5151 if (errno != EAGAIN )
@@ -65,7 +65,7 @@ int foc_mq_handle(mqd_t mq, FAR struct foc_mq_s *h)
6565
6666 /* Verify message length */
6767
68- if (ret != 5 )
68+ if (ret != CONTROL_MQ_MSGSIZE )
6969 {
7070 PRINTF ("ERROR: invalid message length = %d\n" , ret );
7171 goto errout ;
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ static int g_fixed16_thr_cntr = 0;
7070static FAR void * foc_control_thr (FAR void * arg )
7171{
7272 FAR struct foc_ctrl_env_s * envp = (FAR struct foc_ctrl_env_s * ) arg ;
73+ char buffer [CONTROL_MQ_MSGSIZE ];
7374 char mqname [10 ];
7475 int ret = OK ;
7576
@@ -116,6 +117,26 @@ static FAR void *foc_control_thr(FAR void *arg)
116117 goto errout ;
117118 }
118119
120+ /* Make sure that the queue is empty */
121+
122+ while (1 )
123+ {
124+ ret = mq_receive (envp -> mqd , buffer , CONTROL_MQ_MSGSIZE , 0 );
125+ if (ret < 0 )
126+ {
127+ if (errno == EAGAIN )
128+ {
129+ break ;
130+ }
131+ else
132+ {
133+ PRINTF ("ERROR: mq_receive failed errno=%d\n" , errno );
134+ ret = - errno ;
135+ goto errout ;
136+ }
137+ }
138+ }
139+
119140 /* Select control logic according to FOC device type */
120141
121142 switch (envp -> type )
You can’t perform that action at this time.
0 commit comments