1

I have two real-time threads(linux)

First one is to send bytes over serial port (kernel space)

Second one is to read the same bytes(because i used loop-back device) from serial port.

First thread sends data continuously and asynchronously, however;

second thread cannot open the serial port to read..

I used semaphores, but my problem i guess.. is not the synchronization issue, my problem is serial port still in the hand of first thread.

How can I overcome this issue..

I am open to your suggestions,

Best Regards

mexes
  • 23
  • 7
  • When you open your device are you opening it in Read/Write mode, or each one in Read mode only and the other in Write mode only? – Preston Dec 02 '13 at 05:47
  • each one in read mode only, and the other in Write mode only (so means two different code scripts, both on kernel space) – mexes Dec 02 '13 at 06:23
  • So you mean each one is opened in Read/Write, and the other is opened it Write only? If so I don't think this is possible, as the device pipe can only be opened and accessed through a single handle. – Preston Dec 02 '13 at 06:41
  • briefly, first one is write only, second one is read only, however when i compile and insmod read only one, it says "adress in use -98" as a reply for rt_spopen.. – mexes Dec 02 '13 at 08:15
  • writing side works properly, but i cannot read. I use loop-back connector at my COM1. – mexes Dec 02 '13 at 08:20
  • @Preston, can it be the reason I pass the char arrays into sp_read_timed function wrongly..I am looking how to pass char array into a function – mexes Dec 03 '13 at 13:12
  • Unfortunately I don't have enough information to be for sure. You might update your question to post some code samples so that everyone can see what's happening. – Preston Dec 03 '13 at 15:48
  • *"second thread cannot open the serial port to read"* -- Besides showing your code, you need to fully describe the symptoms you saw that lead you to this assumption (i.e. what is the *errno*?). – sawdust Dec 03 '13 at 19:48
  • @sawdust one of them is; Error: rt_spopen and Adress in use -98; On the other hand I was thinking how to minimize my code to post here.. thats why i still couldnt post... – mexes Dec 03 '13 at 20:15
  • @sawdust http://stackoverflow.com/questions/21568883/serial-port-cannot-read-what-i-write i updated my issue right here – mexes Feb 06 '14 at 21:34
  • Why not open your port in read & write by one of the kernel modules, then in the second one just call the `rt_spread`, assuming the port is already open (which it is). – Shahbaz Jan 30 '15 at 14:02
  • thank you @Shahbaz , what I did was to use two different ports that are buried into a desktop case – mexes Mar 19 '15 at 19:19

0 Answers0