candle-usb / candleLight_fw

gs_usb compatible firmware for candleLight, cantact and canable
Other
642 stars 283 forks source link

Clear internal data structures holding unsent frames #168

Open Agasthyahollam opened 1 year ago

Agasthyahollam commented 1 year ago

Hello guys, I would like to implement a feature wherein on sending a CAN frame with a particular ID the internal data structures are all cleared of unsent frames. This feature is required for in case of emergency stop (of the system).

It would be very helpful to get a few pointers from you guys as to how to go about doing this in the proper way.

marckleinebudde commented 1 year ago

The proper solution would be to implement a new control message, i.e. a new GS_USB_BREQ_ and flush the internal buffers and the hardware buffers in USBD_GS_CAN_EP0_RxReady(). Send the control message as needed.

The hack solution would add a check for the particular CAN frame in USBD_GS_CAN_DataOut() and flush the buffers there.