Hi,
Now I have the web pages working I need to look at the serial data again. Do I need to copy the above file, I thought it would install automatically when I updated. According to the updates I am up to date but the version for the CAL_UART installed is V1.0 21/02/2020
Bob
USB serial on Raspberry Pi
-
- Posts: 283
- http://meble-kuchenne.info.pl
- Joined: Sat Mar 19, 2022 4:53 pm
- Has thanked: 25 times
- Been thanked: 32 times
Re: USB serial on Raspberry Pi
Oops, first own goal was looking at an example for a PIC device which is why I could not see the list of other ports.
Now I have selected the Raspberry Pi I have the drop down list but none of them appear to work. It look like the device is showing up as ttyUSB0 but that is not on the list. In the original project on NodeRED I do not recall having to do anything special so am I missing something.
Regards,
Bob
Now I have selected the Raspberry Pi I have the drop down list but none of them appear to work. It look like the device is showing up as ttyUSB0 but that is not on the list. In the original project on NodeRED I do not recall having to do anything special so am I missing something.
Regards,
Bob
-
- Valued Contributor
- Posts: 447
- Joined: Mon Dec 07, 2020 1:00 pm
- Has thanked: 81 times
- Been thanked: 243 times
Re: USB serial on Raspberry Pi
Hi Bob,
As mentioned previously you will need to create a symlink for one of the serial channels to ttyUSB0
This is done from a Linux command prompt.
For further information see my previous example or search Linux ln command and symlink (symbolic link)
Hope that helps
As mentioned previously you will need to create a symlink for one of the serial channels to ttyUSB0
This is done from a Linux command prompt.
For further information see my previous example or search Linux ln command and symlink (symbolic link)
Hope that helps
Re: USB serial on Raspberry Pi
Hi,
I think I have the port moved now, I still cannot see any data but I am wondering if I am using the correct command.
When I plug in to a PC and use a terminal program I get this, the data I am interested in is the 3 lots of 4 on the left. and this is what it looked like on the Raspberry Pi with NodeRED so I am pretty sure I should be using the Receive string option. I do not get anything at all, this is what I see. I tried to include the project file just in case I have missed something obvious but it will not let me.
Bob
I think I have the port moved now, I still cannot see any data but I am wondering if I am using the correct command.
When I plug in to a PC and use a terminal program I get this, the data I am interested in is the 3 lots of 4 on the left. and this is what it looked like on the Raspberry Pi with NodeRED so I am pretty sure I should be using the Receive string option. I do not get anything at all, this is what I see. I tried to include the project file just in case I have missed something obvious but it will not let me.
Bob
-
- Valued Contributor
- Posts: 447
- Joined: Mon Dec 07, 2020 1:00 pm
- Has thanked: 81 times
- Been thanked: 243 times
Re: USB serial on Raspberry Pi
Hi Bob,
I've just had a quick look at your Flowcode and the generated C.
Some thoughts ...
The UART Receive String timeout is limited to 255ms (8 bit variable), hence you need to reduce the 5000.
So I suggest that you reduce to say 200ms and then test the return string for being non-null i.e. InDataString[0] != 0
before you go on to process it.
Maybe check the string length too, just to check you have all of it.
Not sure if your buffer size needs to be a little bigger, due to terminating null or CR/LF etc.
I bit of headroom is always useful
I've just had a quick look at your Flowcode and the generated C.
Some thoughts ...
The UART Receive String timeout is limited to 255ms (8 bit variable), hence you need to reduce the 5000.
So I suggest that you reduce to say 200ms and then test the return string for being non-null i.e. InDataString[0] != 0
before you go on to process it.
Maybe check the string length too, just to check you have all of it.
Not sure if your buffer size needs to be a little bigger, due to terminating null or CR/LF etc.
I bit of headroom is always useful

Re: USB serial on Raspberry Pi
Hi Leigh,
I really appreciate your support on this.
Originally I had the timeout at 100 and changed it to 5 seconds as I think the device sends data every 4 seconds and thought I might be missing it. I did not think of the byte variable.
I did have the string length at 40 but reduced it as I wondered if it might be waiting for end of message terminator or something.
I do not think it is possible to test as you suggest as generally the first byte will be 0, I could test for a minimum length as I am only interested in the first 3 sets. I wonder if Flowcode is stopping at the first space but even so it would have 4 bytes?
I am looking to see if I can find a simple python example to at least make sure the serial port on the Pi is set up as it should be as even if Flowcode was receiving garbage it should be in the InDataString.
Bob
I really appreciate your support on this.
Originally I had the timeout at 100 and changed it to 5 seconds as I think the device sends data every 4 seconds and thought I might be missing it. I did not think of the byte variable.
I did have the string length at 40 but reduced it as I wondered if it might be waiting for end of message terminator or something.
I do not think it is possible to test as you suggest as generally the first byte will be 0, I could test for a minimum length as I am only interested in the first 3 sets. I wonder if Flowcode is stopping at the first space but even so it would have 4 bytes?
I am looking to see if I can find a simple python example to at least make sure the serial port on the Pi is set up as it should be as even if Flowcode was receiving garbage it should be in the InDataString.
Bob
-
- Valued Contributor
- Posts: 447
- Joined: Mon Dec 07, 2020 1:00 pm
- Has thanked: 81 times
- Been thanked: 243 times
Re: USB serial on Raspberry Pi
Hi Bob,
The first character of the string will be '0', but this is 0x30 (or 48 decimal) not 0. Have a look at an ASCII table.
A 100 or 200ms timeout will be fine for a data string every 4 seconds.
Most of the time the receive string will return the null string (first byte 0x00, not the character '0')
If you make the buffer say 40, (looks like minimum needs to be 33+1 for the string null terminator) then you will get the full string
and the timeout will cause a return from the receive string function 100ms after the last character.
So this should synchronise well.
The first character of the string will be '0', but this is 0x30 (or 48 decimal) not 0. Have a look at an ASCII table.
A 100 or 200ms timeout will be fine for a data string every 4 seconds.
Most of the time the receive string will return the null string (first byte 0x00, not the character '0')
If you make the buffer say 40, (looks like minimum needs to be 33+1 for the string null terminator) then you will get the full string
and the timeout will cause a return from the receive string function 100ms after the last character.
So this should synchronise well.