Open same QSerialPort twice
-
Hi,
How can I open same serial port twice ? One for read, one for write ?
When I tried, got
Permission error while locking the device
error which is defined here. -
Hi,
How can I open same serial port twice ? One for read, one for write ?
When I tried, got
Permission error while locking the device
error which is defined here.@huseyinkozan
you can't thats a limitation from the operation system -
Thanks for the reply.
My target OS is embedded Linux, maybe we should move the topic to embedded.
The problem is, my writing thread is a real-time and should not stopped background read operations. Should I try low level serial ?
-
Thanks for the reply.
My target OS is embedded Linux, maybe we should move the topic to embedded.
The problem is, my writing thread is a real-time and should not stopped background read operations. Should I try low level serial ?
@huseyinkozan what kind of embedded linux are we talking here? RTLinux?
Because when your Linux is not realtime, your writing thread will not be realtime either!
-
@J-Hilk Yep, using custom RT patched image at Toradex Colibri imx6. Its real time and write thread works for a long time.
-
@J-Hilk Yep, using custom RT patched image at Toradex Colibri imx6. Its real time and write thread works for a long time.
@huseyinkozan Ok, I'm most certainly out of my depths here than :D
Maybe the OS offer some low level serial port access that would allow parallel access to it. But I don't know where to look 😬
-
Found this, and mentions about two different threads can use it.
It seems I cannot go further with QSerialPort, bacause it have a lock file implementation.
Thanks anyway
-
Found this, and mentions about two different threads can use it.
It seems I cannot go further with QSerialPort, bacause it have a lock file implementation.
Thanks anyway
@huseyinkozan said in Open same QSerialPort twice:
It seems I cannot go further with QSerialPort, bacause it have a lock file implementation.
I've done many embedded software development (with or without realtime OS), I my eyes sharing a serial port between several threads is not a good idea.
There should only be one thread which handle the serial port and this thread could then implement sharing of this resources.
This is, according to my experience, the best way to share a serial port.My 2 cts.
-
@huseyinkozan said in Open same QSerialPort twice:
It seems I cannot go further with QSerialPort, bacause it have a lock file implementation.
I've done many embedded software development (with or without realtime OS), I my eyes sharing a serial port between several threads is not a good idea.
There should only be one thread which handle the serial port and this thread could then implement sharing of this resources.
This is, according to my experience, the best way to share a serial port.My 2 cts.
@KroMignon Thanks for the advice.
I know there is some hardware limitations about UART configuration, and I am considering that.
My target device requires 2msec aligned data, thus I am using a derived SerialPort class with customized writeData().
On the receiving side, I have another device which is transmitting data with same communication options.
The data incoming and outgoing is unrelated to each other.
I do not see any drawbacks. Do you have any suggestions with these conditions ?
-
@KroMignon Thanks for the advice.
I know there is some hardware limitations about UART configuration, and I am considering that.
My target device requires 2msec aligned data, thus I am using a derived SerialPort class with customized writeData().
On the receiving side, I have another device which is transmitting data with same communication options.
The data incoming and outgoing is unrelated to each other.
I do not see any drawbacks. Do you have any suggestions with these conditions ?
@huseyinkozan said in Open same QSerialPort twice:
I do not see any drawbacks. Do you have any suggestions with these conditions ?
IMHO Qt is not designed for realtime applications. According to your previous posts, you are using a custom Linux kernel with RT patches on an i.MX6 CPU.
My way to do this would be to customize the UART driver to handle there the 2ms "window". On driver side, with RT patch, this should be much easier to do, compared to userland level.
And made the UART/driver buffers (transmission and reception) available via /proc/ virtual file system, so you could handle transmission/reception via shell commands to test. -
@huseyinkozan said in Open same QSerialPort twice:
I do not see any drawbacks. Do you have any suggestions with these conditions ?
IMHO Qt is not designed for realtime applications. According to your previous posts, you are using a custom Linux kernel with RT patches on an i.MX6 CPU.
My way to do this would be to customize the UART driver to handle there the 2ms "window". On driver side, with RT patch, this should be much easier to do, compared to userland level.
And made the UART/driver buffers (transmission and reception) available via /proc/ virtual file system, so you could handle transmission/reception via shell commands to test.@KroMignon Thank you very much.