Serial port asynchronous reading

More
28 Aug 2025 10:51 - 28 Aug 2025 11:02 #334027 by ts
Hi.
i need to read every 100 millisec some values from rs232. (Old equipment and i haven't source) and during work have to change this values. Also with this values i switch to working state equipment. I understand command which i have to send and to read.

And now i see only solution when i write all commands on the arduino-like board for connecting with target board, and for upper lever (linuxcnc) via mobdus (arduino as slave). But im trying to find more simple solution with only linuxcnc.

how to do this elegance)?

Regards
 
Last edit: 28 Aug 2025 11:02 by ts.

Please Log in or Create an account to join the conversation.

More
28 Aug 2025 12:51 #334035 by andypugh
Replied by andypugh on topic Serial port asynchronous reading
Does your system have a Mesa card? If it does then you could look at using a Mesa UART.

Otherwise it ought to be possible to use the onboard serial port, but for some reason I haven't seen anyone do that through HAL in realtime.

In theory you ought to be able to do it with inb and outb commands:
stackoverflow.com/questions/47048726/bau...-outb-commands-linux
(note that the advice there is "don't" but they are not considering realtime limitations)

There is an existing hal component that uses the serial port status lines for GPIO
github.com/LinuxCNC/linuxcnc/blob/master...drivers/serport.comp
which it might be possible to tweak. But the fact that nobody seems to makes me wonder if it is impossible for some reason?
The following user(s) said Thank You: ts

Please Log in or Create an account to join the conversation.

More
28 Aug 2025 12:57 - 28 Aug 2025 13:01 #334036 by ts
Replied by ts on topic Serial port asynchronous reading
Andypugh, Thanks for reply!

I didn't use mesa board. I think about ehtercat + rs232 , this is more simple for me (ethercat modules avaible from stock, but mesa is not available). But of course best way to use onboard rs232 to sending and receiving data.

About realtime -This is not critical , because speed is 19200, so i dont need realtime.

I will read links more detailed this evening.
And may be there are some another way if no needed realtime.
Last edit: 28 Aug 2025 13:01 by ts.

Please Log in or Create an account to join the conversation.

More
28 Aug 2025 13:52 #334041 by PCW
Replied by PCW on topic Serial port asynchronous reading
Since it's not realtime, you should be able to make a simple (python?) userspace
hal component using the kernels serial driver.

Please Log in or Create an account to join the conversation.

More
28 Aug 2025 17:54 #334054 by ts
Replied by ts on topic Serial port asynchronous reading
PCW, thanks for your reply!

Is there any example for this solution with userspace hal component?

Please Log in or Create an account to join the conversation.

More
28 Aug 2025 19:19 #334059 by PCW
Replied by PCW on topic Serial port asynchronous reading
There's an old thread here that may give some ideas:

forum.linuxcnc.org/24-hal-components/280...n-cleanup-using-comp

Please Log in or Create an account to join the conversation.

Time to create page: 0.060 seconds
Powered by Kunena Forum