Need an advice about RT/HAL primitives to use for a USART "proxy" application
Posted: Mon May 16, 2016 10:38 am
Hello, I'm completely new to ChibiOS/RT and HAL but I've read the ChibiOS book and tinkered with the source codes to understand its structure, so I have some understanding.
I must make a decision about the application structure (should I use synchronous messages or events or buffer queues? etc..) and I'm still not very familiar with their internals, so any help will be appreciated. I don't want code, just advice about the general structure of the code.
There are two devices which talk to each other through USART using a well known protocol.
[nfo]------------ ------------
| | | |
| device 1 | | device 2 |
| >TX---------RX> |
| | | |
| <RX---------TX< |
|__________| |__________|[/nfo]
The protocol consists of messages of variable lengths:
0xFF 0xNN (0xNN bytes) (CRC)
I need to create a proxy (using a STM32 Nucleo board), a better word would be a MITM device:
[nfo]_ -----------------
|sens 1 |sens 2 |
| | |
| TX RX | TX RX |
|_V__^__|_V__^__|
\ \ | |
\__- / /
------------ -\\--||| ------------
| | |MITM | | |
| device 1 | | | | device 2 |
| >TX--->RX--TX>--RX> |
| | | | | |
| <RX---<TX--RX<--TX< |
|__________| |______| |__________|[/nfo]
As you can see the MITM uses 4 USART interfaces. Depending on the 2 sensors data the MITM should add/edit/delete packets in either direction (transparently for the device 1 and device 2).
It can't just blindly pass the data. It should get a packet, parse it, make a decision (about deleting or editing) based on sensors information and only then pass (or not) it forward, possibly with additional (inserted in between) data packets.
What threads and communication mechanisms between them do you suggest to use?
Thank you for your time!
I must make a decision about the application structure (should I use synchronous messages or events or buffer queues? etc..) and I'm still not very familiar with their internals, so any help will be appreciated. I don't want code, just advice about the general structure of the code.
There are two devices which talk to each other through USART using a well known protocol.
[nfo]------------ ------------
| | | |
| device 1 | | device 2 |
| >TX---------RX> |
| | | |
| <RX---------TX< |
|__________| |__________|[/nfo]
The protocol consists of messages of variable lengths:
0xFF 0xNN (0xNN bytes) (CRC)
I need to create a proxy (using a STM32 Nucleo board), a better word would be a MITM device:
[nfo]_ -----------------
|sens 1 |sens 2 |
| | |
| TX RX | TX RX |
|_V__^__|_V__^__|
\ \ | |
\__- / /
------------ -\\--||| ------------
| | |MITM | | |
| device 1 | | | | device 2 |
| >TX--->RX--TX>--RX> |
| | | | | |
| <RX---<TX--RX<--TX< |
|__________| |______| |__________|[/nfo]
As you can see the MITM uses 4 USART interfaces. Depending on the 2 sensors data the MITM should add/edit/delete packets in either direction (transparently for the device 1 and device 2).
It can't just blindly pass the data. It should get a packet, parse it, make a decision (about deleting or editing) based on sensors information and only then pass (or not) it forward, possibly with additional (inserted in between) data packets.
What threads and communication mechanisms between them do you suggest to use?
Thank you for your time!