I am using TinyCLR on an SCM20260D in order to read a J1708 data stream. The J1708 protocol marks an end of message by having a certain number of bits of inactivity. In this case my baud rate is 9600 and the system uses 3 bits of inactivity to mark the end of a message, so the timing works out to 312.5 microseconds of inactivity. Is there any way to set a timer that hits after this time elapses or a way count inactive bits in order to separate my messages, as currently I am using a 1 ms timeout which is too long and results in messages being clumped together.
The normal way I do this with C/C++ is to reset the timer every time a byte is received and set a flag when it times out, indicating a msg has arrived and ready to be decoded. This is also how Modbus works. The flag is checked in a state machine that I implement in the main code loop.
A lot of my work is with Microchip processors so usually PIC18 or PIC32, and I often use the same tactic. The issue is that I don’t know if TinyCLR has any access to hardware timers that I could use, just millisecond based timer objects or thread sleep functions.
I did think of that, but haven’t had time to test it. It would, however, be much easier if I had some way to access hardware timers, or simply a way to support microsecond based timers or thread.sleep functions.