News:

Let's find out together what makes a PIC Tick!

Main Menu

Serial revisited

Started by See_Mos, Feb 12, 2021, 02:57 PM

Previous topic - Next topic

See_Mos

I am confused and my old head is hurting trying to figure out how to receive DWORD variables serially

It is years since I did any serial programming, 2006 in fact, and Proton has come a long way since then.  I have many pieces of code going back to 2002 but sorting out what is what is not easy.

In the past I did it with packets of data because I only needed byte size values and with a bit of work I could use the same method again and rebuild the numbers at the receive end.

Sending the numbers is easy.

So I am looking for suggestions for a neat way of receiving DWORD numbers serially so that the number can be manipulated further.

The number requires a fixed number of digits depending on the final application up to a maximum of 8 digits with leading zero(s)

I think my next move is to backup then remove all of the masses of Proton from my main PC and do a reinstall so that I am not distracted by all of the old files, samples and .INC files etc.


TimB

Basic questions

1 Can you wait in a loop for the data? eg Hrsin MyDword or perhaps with a time out Hrsin.
2 Does it need to be done in the back ground eg an interrupt?
3 Do you know the way the data is being sent eg little endian

tumbleweed

If you want it to be somewhat universal, convert the numbers to ASCII strings and send them with some sort of delimiter between values.

It's more code but it has the advantage that it always works no matter what mix of data you send.
If you send the numbers as pure binary data then you always have to worry about the two sides being in sync, using the same types, etc.

It also has the advantage that you can view the data stream easily with a serial terminal.