Manage serial port from two processes simultaneosly

前端 未结 3 1479
情书的邮戳
情书的邮戳 2021-01-28 08:10

I have the following scenario:

  • Rasperry pi connected to a device via Serial port
  • 3g Dongle connected to the raspberry (with the ability to make/recieve ca
相关标签:
3条回答
  • 2021-01-28 08:17

    Like all good GSM things there's a specification for that :)

    GSM 07.10 is the specification and there are libraries out there for some time that can support you. Some are libraries you can build into your server systems and some are actual daemons.

    A quick google for "gsm multiplexing" will get your started that I am sure.

    0 讨论(0)
  • 2021-01-28 08:22

    You may write a single service that communicates with the real serial port but offers two virtual serial ports itself like described here Virtual Serial Port for Linux

    0 讨论(0)
  • 2021-01-28 08:28

    I had a similar problem managing a serial port between some independent processes. Finally my best solution was to use Redis to listen for calls to the port.

    The process that wants to send something, publishes through redis, in the channel 'uart_request' a json with the arguments to make the call to the serial port, and also a hash ('hash_message') made with the timestamp. Just before posting the json, the process subscribes to 'hash_message'.

    Finally, a process listens for the posts in 'uart_request'. When a post arrives, take the 'hash_message' from the json, make the call to the serial port, wait for the response and post the response in 'hash_message'.

    The point is that there is just one process that control the serial port, so its not necessary to open and close. Works really good.

    0 讨论(0)
提交回复
热议问题