lundi 8 juin 2015

Design Pattern for handling interrupt data

I am developing a firmware application implemented in C, and I want to know what is a good design pattern for this kind of situation

  1. In main loop, I will get interrupt when I received data from a device using UART communication
  2. I would send a AT command and wait for the reply from the device, if the device reply OK, i will send the next AT command until all the commands finish
  3. If the device reply NOK (not ok), i will resend the command again

I have considered STATE machine, but I still think the implementation is not elegant, because I was waiting for the response in the main loop, to transit to another state.

Which design pattern should I implement?

Aucun commentaire:

Enregistrer un commentaire