1

Background

Working as a software engineer in the field of electronics, I often find that none of the existing design patterns i.e. GoF typically fit the bill for what I need to do. One of the patterns that I frequently use works something like this:

  1. Open up a connection to some electronic device.
  2. Transmit a command to that electronic device, to make it perform some work.
  3. Block the thread until that electronic device does whatever it needs to do, and responds back saying that it (the device) finished.
  4. Unblock the thread once I receive the response from the device, and continue executing.

This pattern is typically used in scenarios where I need to talk to IEEE 488.2 SCPI devices like multi-meters. I typically write libraries that handle the commands/response from the devices in this manner. An example is where I might do something such as:

  1. Connect to the meter.
  2. Tell the meter to give me the voltage.
  3. Wait for the meter to respond back with the voltage, then unblock once it does so.
  4. Unblock, and process the received voltage (e.g. return it from some library GetVoltage method).

Question

I would like to know what the formal name for doing this is. I've heard command-response but am not sure about that. I know it's not controller-pattern, and I also know that this isn't the command-pattern.

Is there a formal name for this kind of a design-pattern/system?

  • 2
    It looks very much like any other blocking I/O call, e.g. reading from a file. You just do the thread blocking and waiting in your own library, and for e.g. file I/O the kernel does it for you. – 9000 May 16 '16 at 13:13
  • @9000 Interesting, the reason I am looking for the formal name for this... Is that then I might be able to do more research, and figure out more methods for similar patterns related to this field of software engineering. In many of these situations you're forced to block because you need the response back from the device to know that the transmission went through (that the device actually received it). – Snoop May 16 '16 at 13:15
  • 1
    Because design pattern is used to describe things like the GoF so much, you may want to avoid the term in your searches. – JeffO May 16 '16 at 13:39
  • @JeffO Yeah absolutely, not really sure what to call this. Maybe it's a control-system. Dunno. – Snoop May 16 '16 at 13:55
  • Can you explain why what you're describing isn't just the routine behavior of an ordinary method call? If you're looking for some term to Google to find out how to talk to your meter, I doubt we have that. Find the manuals for the meter and study the communication protocols. – Robert Harvey May 16 '16 at 14:43
3

According to the collection of embedded system design patterns at http://www.eventhelix.com/RealtimeMantra/Patterns/, what you're talking about is called the Serial Wait State Pattern, which contrasts to the more flexible/efficient but harder to use Parallel Wait State Pattern.

  • This is exactly what I was looking for. – Snoop May 16 '16 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.