Page 1 of 3

USB serial on Raspberry Pi

Posted: Sat Aug 13, 2022 10:44 pm
by RGV250
Hi,
I have a bit of code running on a Raspberry Pi using Node Red. I would like to convert it to Flowcode but I appear to have fallen at the first hurdle.
I have not got a Raspberry Pi licence yet but thought I would look first. I had a look at the webserver example https://www.matrixtsl.com/wiki/index.ph ... etworking) and tried adding a USB serial as that is what I thought I would need. It looks like this is not supported for the Pi, looking at the Node Red code the port is something like /dev/ttyUSB0. Is it possible to use USB serial ports on the Raspberry Pi with Flowcode?

Regards,
Bob

Re: USB serial on Raspberry Pi

Posted: Sun Aug 14, 2022 8:18 am
by kersing
USB serial is to implement a device that can be connected to a PC or Raspberry Pi. Probably the reverse of what you are looking for. To access a USB serial connected to the Raspberry Pi you need to use a serial component. The Raspberry Pi OS translates such devices to serial ports as suggested by the /dev/ttyXX naming.

Re: USB serial on Raspberry Pi

Posted: Sun Aug 14, 2022 10:33 am
by RGV250
Hi Kersing,
I do not follow, I have looked at all the component libraries / comms and none of them seem to be able to select the address, just a port/pin number.

Bob

Re: USB serial on Raspberry Pi

Posted: Sun Aug 14, 2022 3:49 pm
by LeighM
Hi Bob,
If I correctly understand what you are trying to do,
and you already have device /dev/ttyUSB0 installed,
then you should be able to unlink the symlink /dev/serial1
(which is normally linked to /dev/ttyAMA0)
and link it to /dev/ttyUSB0 instead.

Code: Select all

unlink /dev/serial1
ln -s /dev/ttyUSB0 /dev/serial1
Then use the Flowcode UART component set to Channel 2,
which uses /dev/serial1

Re: USB serial on Raspberry Pi

Posted: Sun Aug 14, 2022 8:01 pm
by RGV250
Hi LeighM,
I am assuming I need to add that code somewhere in the config.txt file.

Which component do I need to use as when I look at UART (RS232) there is only software or channel 1, I wonder if it is because I have not got the licence yet? I am going to try on another PC as I did have a load of grief with ESP32 on windows7.

Are you limited to only the one USB/TTL serial device then? I had planned to use at least 2 but I can probably get away with using pins.

Bob

Re: USB serial on Raspberry Pi

Posted: Tue Aug 16, 2022 12:58 pm
by LeighM
Hi,
Sorry, yes, it could be Channel 1, /dev/serial0
There are some differences between versions.

Ben,
Maybe the CAL UART Init could be extended with more channels, /dev/serial2 etc.,
then users can symlink to any installed serial devices.
Probably just need to repeat the same tx rx pins in the FCD, as these aren't used by the CAL anyway.
Although references to pins in the component could be confusing, what happens if they are not specified in the FCD?
Just a thought.

Re: USB serial on Raspberry Pi

Posted: Wed Aug 17, 2022 12:35 pm
by BenR
Thanks Leigh some good suggestions there.

I'll add some more UART channels to the FCD and see if I can add a special case to the UART component so it can still work if pins are not provided.

Re: USB serial on Raspberry Pi

Posted: Wed Aug 17, 2022 1:38 pm
by BenR
I've made a change if you want to have a look and see what you think.

Now added 5 hardware UART channels to all RPI defintions which should list their /dev/serial0 - /dev/serial4 as part of the channel name.

I'm guessing that "Channel 1 - /dev/serial0" does still have the hardware UART pins so I've left those defined but the others are all software defined and so should hide the pin properties.

Re: USB serial on Raspberry Pi

Posted: Wed Aug 17, 2022 3:10 pm
by LeighM
Thanks Ben.
A lot of edits eh, just a few missed 8-) see attached

Re: USB serial on Raspberry Pi

Posted: Wed Aug 17, 2022 3:24 pm
by BenR
Excellent thanks Leigh that's now been applied here, not sure how I missed those ones :D