@@ -155,48 +155,44 @@ int can_input(struct net_driver_s *dev)
155
155
{
156
156
FAR struct can_conn_s * conn = NULL ;
157
157
int ret = OK ;
158
+ uint16_t buflen = dev -> d_len ;
158
159
159
160
do
160
161
{
161
- /* FIXME Support for multiple sockets??? */
162
-
163
162
conn = can_nextconn (conn );
164
- }
165
- while (conn && conn -> dev != 0 && dev != conn -> dev );
166
-
167
- if (conn )
168
- {
169
- uint16_t flags ;
170
163
171
- /* Setup for the application callback */
164
+ if (conn && (conn -> dev == 0x0 || dev == conn -> dev ))
165
+ {
166
+ uint16_t flags ;
172
167
173
- dev -> d_appdata = dev -> d_buf ;
174
- dev -> d_sndlen = 0 ;
168
+ /* Setup for the application callback */
175
169
176
- /* Perform the application callback */
170
+ dev -> d_appdata = dev -> d_buf ;
171
+ dev -> d_sndlen = 0 ;
172
+ dev -> d_len = buflen ;
177
173
178
- flags = can_callback ( dev , conn , CAN_NEWDATA );
174
+ /* Perform the application callback */
179
175
180
- /* If the operation was successful, the CAN_NEWDATA flag is removed
181
- * and thus the packet can be deleted (OK will be returned).
182
- */
176
+ flags = can_callback (dev , conn , CAN_NEWDATA );
183
177
184
- if ((flags & CAN_NEWDATA ) != 0 )
185
- {
186
- /* No.. the packet was not processed now. Return -EAGAIN so
187
- * that the driver may retry again later. We still need to
188
- * set d_len to zero so that the driver is aware that there
189
- * is nothing to be sent.
178
+ /* If the operation was successful, the CAN_NEWDATA flag is removed
179
+ * and thus the packet can be deleted (OK will be returned).
190
180
*/
191
181
192
- nwarn ("WARNING: Packet not processed\n" );
193
- ret = - EAGAIN ;
182
+ if ((flags & CAN_NEWDATA ) != 0 )
183
+ {
184
+ /* No.. the packet was not processed now. Return -EAGAIN so
185
+ * that the driver may retry again later. We still need to
186
+ * set d_len to zero so that the driver is aware that there
187
+ * is nothing to be sent.
188
+ */
189
+
190
+ nwarn ("WARNING: Packet not processed\n" );
191
+ ret = - EAGAIN ;
192
+ }
194
193
}
195
194
}
196
- else
197
- {
198
- ninfo ("No CAN listener\n" );
199
- }
195
+ while (conn );
200
196
201
197
return ret ;
202
198
}
0 commit comments