Home » Eclipse Projects » Kura » Enumerating Serial Ports in Kura(Raspberry Pi)
Enumerating Serial Ports in Kura [message #1729089] |
Mon, 11 April 2016 06:53 |
Said Ucar Messages: 56 Registered: June 2015 |
Member |
|
|
Hi,
I'm using USB Ports of Raspberry Pi for Serial Communication. I had a lot of trouble with doing this, and finally I understood what is going on.
I used javax.comm.CommPortIdentifier to check if port exist or not. But sometimes, my USB Ports didn't listed in here. When I check it from Raspberry's terminal, (/dev/ttyUSBx), my port is listed here but I can't get it from inside Kura (by Java).
When I looked inside this CommPortIdentifier class, I noticed that, port names are loading once. The portname loading is in a static block, so the portname list is belongs, when CommPortIdentifier's ClassLoader loads this class. After the class loaded, if you plug another usb or unplug existing one, the port list doesn't change.
Short story, in IoT, we want to build live systems, plug-n- play systems. And this Serial Port scanning is a little bit weird. I have two question (idea),
1 - The javax.comm packet is open for contribution? I believe something should be done about this port name scanning, everything in Kura and IoT world modular, but , I have to restart my Raspberry if I plug USB.
2 - AFAIK, if we plug more than one USB to the device, we need device vid/pid beyond the port name (dev/ttyUSBx). I looked python serial library and love it. I think we should consider it as a reference.
I'm eager to hear your ideas,
Thanks in advance
Said.
[Updated on: Mon, 11 April 2016 13:08] Report message to a moderator
|
|
| |
Re: Enumerating Serial Ports in Kura [message #1733355 is a reply to message #1731109] |
Thu, 26 May 2016 19:00 |
Said Ucar Messages: 56 Registered: June 2015 |
Member |
|
|
Hi Ilya,
Your scenarios seem possible. For now, I use one usb2serial device and there is no other device, so, I think I didn't faced your scenario 2. Scenario 1 could be, I will deep look at it. Thanks for you clear examples. But, what I want to say, in the javax.comm package, the loading ports part is in a static block. This means, the block executed only one time, on start-up (When the class load by its classloader). Hence, If I start Kura and my bundle without usb2serial device plugged, after bundle starts, it means nothing to plug usb device. javax.comm never reload ports. This is my problem (1) . To solve my problem to, it is required to solve problem 1 either. I hope I am more clear now.
Sorry for late reply. I was busy for other works.
Thanks again,
Best Regards
Said.
|
|
|
Re: Enumerating Serial Ports in Kura [message #1746888 is a reply to message #1733355] |
Mon, 07 November 2016 10:20 |
Said Ucar Messages: 56 Registered: June 2015 |
Member |
|
|
Hi,
Recently, I faced same problem again and I want to ask what can I do under below circumstances.
I think the problem is this, on startup I have ttyUSB0 and I open this SerialPort in my bundle. Somehow, the device I plugged in to Pi is reset and I catch an Exception in my bundle. At this point, the device name changes to ttyUSB1 under my Pi. Due to static loader in javax.comm, I couldn't see this ttyUSB1 device in my portlist. When I add manually using the method CommPortIdentifier.addPortName(), I couldn't open anyway. There is some examples about this port list loading in the internet, like using classloader to reload CommPort class etc. I'm really stuck at this point and if you have an idea it would be great. What should I do when I catch an exception while using both InputStream and OutputStream. Should I try to close port or do nothing? By the way, is Kura Connection Api based on javax.comm or rxtx library?
Best regards,
Said.
|
|
| | | | | |
Goto Forum:
Current Time: Wed Apr 24 16:08:30 GMT 2024
Powered by FUDForum. Page generated in 0.03574 seconds
|