Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finding serial port name #2

Closed
DebbyX3 opened this issue Feb 15, 2021 · 20 comments
Closed

Finding serial port name #2

DebbyX3 opened this issue Feb 15, 2021 · 20 comments

Comments

@DebbyX3
Copy link

DebbyX3 commented Feb 15, 2021

Hi, I finally managed to get a USB to IrDA device (they're so difficult to find) but I have some troubles finding or maybe binding my device with a serial port.
Tried my USB dongle with the last Ubuntu release, but I had no luck cause the drivers were not present anymore, so I had to stick with an older version, Ubuntu 15. This version recognizes and installs the drivers just fine.

Usb dongle specs using dmesg:

 [  690.278258] usb 1-2: new low-speed USB device number 15 using xhci_hcd
 [  690.467325] usb 1-2: New USB device found, idVendor=07d0, idProduct=4959
 [  690.467331] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
 [  690.467334] usb 1-2: Product: USB to IRDA
 [  690.467336] usb 1-2: Manufacturer: Kingsun CO.
 [  690.468264] KingSun KS-959 IRDA/USB found at address 15, Vendor: 7d0, Product: 4959
 [  690.468509] net irda0: IrDA: Registered KingSun KS-959 device irda0

with lsusb:

Bus 001 Device 015: ID 07d0:4959 Dazzle Kingsun KS-959 Infrared Adapter

and using ifconfig -a

irda0     Link encap:IrLAP  HWaddr 6a:96:67:cb  
          UP RUNNING NOARP  MTU:2048  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4894 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:8 
          RX bytes:0 (0.0 B)  TX bytes:74121 (74.1 KB)

Also, I attached the dongle using: sudo irattach irda0 -s and then tried sudo irdadump to see if the device is working, which it is because it displays various messages waiting for a connection with a device such an old infrared phone. Unfortunately i don't have an old device that supports IrDA so i can't really try this part, but at this point I'm pretty confident that the USB dongle is at least working.

The problem is that I can't find or can't figure out how to attach the dongle with a serial port, since your script uses this to communicate.
I tried using ircomm or/and ircomm-tty to create a port of some sort, but honestly at this point I don't really know what I was doing (to my understanding ircomm creates virtual ports).

I tried using various ports in your code (I'm referring to 3ds.py since it seems the most basic and I read in the other issue to try blasting a remote control to see if something is captured), such as ttyS0 or ttyS1, also tried using ircomm ports but didn't work.

Depending on the port tried, 3ds.py shows:

  File "3ds.py", line 4, in <module>
    ser = serial.Serial('/dev/ttyS0',115200)
  File "/home/ubuntu/.local/lib/python2.7/site-packages/serial/serialutil.py", line 244, in __init__
    self.open()
  File "/home/ubuntu/.local/lib/python2.7/site-packages/serial/serialposix.py", line 332, in open
    self._reconfigure_port(force_update=True)
  File "/home/ubuntu/.local/lib/python2.7/site-packages/serial/serialposix.py", line 401, in _reconfigure_port
    raise SerialException("Could not configure port: {}".format(msg))
**serial.serialutil.SerialException: Could not configure port: (5, 'Input/output error')**

or just hangs waiting for IR signals that doesn't receive even when I blast a remote control.

Do you have any suggestions about the serial port situation? How did you managed to use your USB dongle as a serial device?

Thank you!!

@HubSteven
Copy link
Owner

HubSteven commented Feb 22, 2021

When I plug in my IrDA adapter dmesg tells me this:

[165174.290018] usb 1-1.3: New USB device found, idVendor=18ec, idProduct=3118, bcdDevice= 0.01
[165174.290034] usb 1-1.3: New USB device strings: Mfr=1, Product=3, SerialNumber=0
[165174.290046] usb 1-1.3: Product: USB TO IRDA
[165174.290058] usb 1-1.3: Manufacturer: ARKMICRO
[165174.290586] usb 1-1.3: config 0 descriptor??
[165174.373482] usbcore: registered new interface driver ark3116
[165174.373540] usbserial: USB Serial support registered for ark3116
[165174.373637] ark3116 1-1.3:0.0: ark3116 converter detected
[165174.377257] ark3116 ttyUSB0: using IrDA mode
[165174.381860] usb 1-1.3: ark3116 converter now attached to ttyUSB0

So my adapter already attaches to a serial port by itself at /dev/ttyUSB0.
It seems your irda adapter driver needs a bit more work to get it attached to a serial port.
From what I've read online regarding your adapter (https://rigacci.org/wiki/doku.php/doc/appunti/hardware/irda_usb_dapter) it seems your very close to solving this issue.

After you plugged in your USB irda adapter you need to run ircomm-tty (which you already did), this should create a com port at /dev/ircomm0. If it doesn't work try run irattach irda0.

Now run python 3ds_write.py /dev/ircomm0, this will emulate an amiibo IR reader without an amiibo placed on top of it.

Hope this helps!

@agtbaskara
Copy link

I also got the same problems. I have Dazzle Kingsun KS-959 Infrared Adapter and MA-620 Infrared Adapter in secondhand condition. I try to use them, but unfortunately, both of them didn't seem to work. I use Ubuntu 20.04 running in VMWare with IrDA driver from https://github.com/cschramm/irda.

I have followed the guide from https://rigacci.org/wiki/doku.php/doc/appunti/hardware/irda_usb_dapter for the KS-959. From http://sparcher.blogspot.com/2016/11/howto-some-experience-with-usb-irda.html for the MA-620, and I got no luck on both. The adapter just blinking when there is an IR light from the 3DS, but I cannot write or read any data (there is not even garbage data when I check the serial port using Putty). I have also try to use irattach and ircomm-tty.

I think your IrDA Adapter (UIR-22) is a special case where it works without needing any setup.

For reference this is the dmesg output for the Dazzle Kingsun KS-959 Infrared Adapter:

[  259.240701] usb 2-2.2: new low-speed USB device number 6 using uhci_hcd
[  259.513171] usb 2-2.2: New USB device found, idVendor=07d0, idProduct=4959, bcdDevice= 1.00
[  259.513173] usb 2-2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  259.513174] usb 2-2.2: Product: USB to IRDA
[  259.513175] usb 2-2.2: Manufacturer: Kingsun CO.
[  259.544066] irda: loading out-of-tree module taints kernel.
[  259.544254] irda: module verification failed: signature and/or required key missing - tainting kernel
[  259.546535] NET: Registered protocol family 23
[  259.549048] KingSun KS-959 IRDA/USB found at address 6, Vendor: 7d0, Product: 4959
[  259.549483] net irda0: IrDA: Registered KingSun KS-959 device irda0
[  259.553971] usbcore: registered new interface driver ks959-sir

lsusb output for the Dazzle Kingsun KS-959 Infrared Adapter:

Bus 002 Device 006: ID 07d0:4959 Dazzle Kingsun KS-959 Infrared Adapter

dmesg output for the MA-620 Infrared Adapter:

[  167.272838] usb 2-2.2: new full-speed USB device number 5 using uhci_hcd
[  167.543048] usb 2-2.2: New USB device found, idVendor=0df7, idProduct=0620, bcdDevice= 0.10
[  167.543051] usb 2-2.2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[  167.582559] usbcore: registered new interface driver usbserial_generic
[  167.582880] usbserial: USB Serial support registered for generic
[  167.587251] usbcore: registered new interface driver pl2303
[  167.587259] usbserial: USB Serial support registered for pl2303
[  167.587271] pl2303 2-2.2:1.0: pl2303 converter detected
[  167.609022] usb 2-2.2: pl2303 converter now attached to ttyUSB0

lsusb output for the MA-620 Infrared Adapter:

Bus 002 Device 005: ID 0df7:0620 Mobile Action Technology, Inc. MA-620 Infrared Adapter

@HubSteven
Copy link
Owner

Does your ma-620 irda adapter appear as a serial port in device manager in windows?

@agtbaskara
Copy link

Nope even though the MA-620 uses a PL2303 USB to UART chip, Windows won't detect it. There is no MA-620 driver for Windows 7 and beyond. I even try to force install the PL2303 driver to the device but still no luck.

@agtbaskara
Copy link

I also have already try to use the MA-620 serial port (/dev/ttyUSB0) directly without using the IrDA driver. I think the MA-620 has a kind of 'layer' for sending and reading Serial Infrared data so we cannot use the serial port as is.

@DebbyX3
Copy link
Author

DebbyX3 commented Mar 14, 2021

When I plug in my IrDA adapter dmesg tells me this:

[165174.290018] usb 1-1.3: New USB device found, idVendor=18ec, idProduct=3118, bcdDevice= 0.01
[165174.290034] usb 1-1.3: New USB device strings: Mfr=1, Product=3, SerialNumber=0
[165174.290046] usb 1-1.3: Product: USB TO IRDA
[165174.290058] usb 1-1.3: Manufacturer: ARKMICRO
[165174.290586] usb 1-1.3: config 0 descriptor??
[165174.373482] usbcore: registered new interface driver ark3116
[165174.373540] usbserial: USB Serial support registered for ark3116
[165174.373637] ark3116 1-1.3:0.0: ark3116 converter detected
[165174.377257] ark3116 ttyUSB0: using IrDA mode
[165174.381860] usb 1-1.3: ark3116 converter now attached to ttyUSB0

So my adapter already attaches to a serial port by itself at /dev/ttyUSB0.
It seems your irda adapter driver needs a bit more work to get it attached to a serial port.
From what I've read online regarding your adapter (https://rigacci.org/wiki/doku.php/doc/appunti/hardware/irda_usb_dapter) it seems your very close to solving this issue.

After you plugged in your USB irda adapter you need to run ircomm-tty (which you already did), this should create a com port at /dev/ircomm0. If it doesn't work try run irattach irda0.

Now run python 3ds_write.py /dev/ircomm0, this will emulate an amiibo IR reader without an amiibo placed on top of it.

Hope this helps!

Thanks for your tips
I tried your suggestions on multiple versions of Ubuntu, but no luck unfortunately. I may have to try again using an even older version of Ubuntu.
In the meantime, I managed to get my hands on an old laptop with a built-in IRda port, but it is very old and only runs outdated Ubuntu versions (also because the laptop has like 256mb of RAM). I briefly tried your script using the built-in port in the laptop but I had some troubles getting the correct drivers, and locating in what Ubuntu version they are available. So far, it didn't work, but I have to experiment more for sure

@agtbaskara I noticed that we have the same USB dongle and I'm starting to think that a layer or something is missing, cause the system doesn't recognize it as a serial port
Regarding the Windows problem, have you tried to plug your other dongle in a Win XP machine? Usually older machines would recognize Irda devices much better. The same happened to me using the Kingsun one: it is recognized in XP and it installed with no problems. The only thing is that you need to provide the correct drivers: mine came with the dongle, but I found them even online and only for 32 bits machines (that explained why I wasn't able to install them on a newer PC)

@agtbaskara
Copy link

@DebbyX3 I tried both of my adapters to a Windows XP Virtual Machine. After installing the proper drivers, both were detected as Infrared Devices rather than Serial/COM devices. I also already tried to use IrCOMM2k (Windows version of ircomm-tty) and still no luck.

For reference, here the screenshot of both device properties:

Screenshot 2021-03-15 045102

Screenshot 2021-03-15 050200

@HubSteven
Copy link
Owner

HubSteven commented Mar 14, 2021

@agtbaskara could you open the com port in that was created using Ircomm2k and point a random ir tv remote at the irda adapter?
Does it show anything in the terminal?

@agtbaskara
Copy link

@HubSteven I have tried using Putty with the 3DS on the COM port created by IrCOMM2k, and there is no garbage data, only an empty terminal. I also tried to read/sniff the 3DS while communicating with Circle Pad Pro, and it is still empty.

Besides Putty, I also use a simple python script that directly reads and prints the serial data, but still no luck.

@HubSteven
Copy link
Owner

HubSteven commented Mar 14, 2021

When you send data using the terminal do you see the ir led flicker of the irda adapter? You can check this by using the camera on your phone. Make sure your room is completely dark.

@agtbaskara
Copy link

agtbaskara commented Mar 14, 2021

I think to run the program we need an adapter that can directly translate Serial data to Infrared Signal.
After some searching, I think an MCP2120 based adapter maybe will work. This kind of adapter basically just a USB to Serial chip + Irda Controller. Because it just uses a common USB to Serial driver shouldn't be a problem. Unfortunately, I only have found 2 of these adapters:

One of them is a DIY board, and one of them is a quite old product. If this adapter works with 3DS, we theoretically can port this project to an Arduino by utilizing the MCP2120+IR Transceiver. A similar project has been done before for the PSP in here https://trandi.wordpress.com/2010/01/09/irda_mcp2120_tfdu4300_ftdi_ttl-232_capacitor_crystal_7-3728/.

EDIT: This website also has a good resource for future implementation https://www.societyofrobots.com/electronics_irda_tutorial.shtml

@HubSteven
Copy link
Owner

I think to run the program we need an adapter that can directly translate Serial data to Infrared Signal.
After some searching, I think an MCP2120 based adapter maybe will work. This kind of adapter basically just a USB to Serial chip + Irda Controller. Because it just uses a common USB to Serial driver shouldn't be a problem. Unfortunately, I only have found 2 of these adapters:

One of them is a DIY board, and one of them is a quite old product. If this adapter works with 3DS, we theoretically can port this project to an Arduino by utilizing the MCP2120+IR Transceiver. A similar project has been done before for the PSP in here https://trandi.wordpress.com/2010/01/09/irda_mcp2120_tfdu4300_ftdi_ttl-232_capacitor_crystal_7-3728/.

EDIT: This website also has a good resource for future implementation https://www.societyofrobots.com/electronics_irda_tutorial.shtml

I've actually thought of the same thing; to implement everything in hardware instead of software. Unfortnutaly I've bever had the time to do so but it's definitely possible.

Btw I've discovered why you PL2303 based adapter gets recognized as an irda device instead instead of an vcp (virtual com port). According to the datasheet of the pl2303 in your case there is an external ROM chip connected to the pl2303 which sets a custom pid and vid. Thats why brute forcing the vcp driver didnt work. If you disconnect this ROM it will return to the orginal pid and vid of the vcp driver.

Could you make a picture of the PCB of the adapter?

@agtbaskara
Copy link

When you send data using the terminal do you see the ir led flicker of the irda adapter? You can check this by using the camera on your phone. Make sure your room is completely dark.

There is a light every few seconds, but I believe this light is some kind of heartbeat signal for IrDA device discovery rather than the output from serial terminal.

@agtbaskara
Copy link

I think to run the program we need an adapter that can directly translate Serial data to Infrared Signal.
After some searching, I think an MCP2120 based adapter maybe will work. This kind of adapter basically just a USB to Serial chip + Irda Controller. Because it just uses a common USB to Serial driver shouldn't be a problem. Unfortunately, I only have found 2 of these adapters:

One of them is a DIY board, and one of them is a quite old product. If this adapter works with 3DS, we theoretically can port this project to an Arduino by utilizing the MCP2120+IR Transceiver. A similar project has been done before for the PSP in here https://trandi.wordpress.com/2010/01/09/irda_mcp2120_tfdu4300_ftdi_ttl-232_capacitor_crystal_7-3728/.
EDIT: This website also has a good resource for future implementation https://www.societyofrobots.com/electronics_irda_tutorial.shtml

I've actually thought of the same thing; to implement everything in hardware instead of software. Unfortnutaly I've bever had the time to do so but it's definitely possible.

Btw I've discovered why you PL2303 based adapter gets recognized as an irda device instead instead of an vcp (virtual com port). According to the datasheet of the pl2303 in your case there is an external ROM chip connected to the pl2303 which sets a custom pid and vid. Thats why brute forcing the vcp driver didnt work. If you disconnect this ROM it will return to the orginal pid and vid of the vcp driver.

Could you make a picture of the PCB of the adapter?

I don't think making the MA-620 adapter detected as a COM port in Windows will help much. The adapter was already detected as a Serial port in Linux, and I already tried to use it before.

Anyway, here is the PCB:

aaaa

bbb

@HubSteven
Copy link
Owner

HubSteven commented Mar 17, 2021

Hmmm, it really surprises me that one of the leds flickers when you don't send any data, this shouldn't happen when the device is configured as a com port. From what I can see on the PCB is seems both leds are connected directly to tx and rx of the prolific chip.

Do you have access to an oscilloscope, that way we can probe what is actually being send.

You could also try to remove the 8 legged chip above the pl2303. This will make it a normal usb serial device again in windows.

@HubSteven
Copy link
Owner

Is the IR sensor bidirectional?

@HubSteven
Copy link
Owner

Looks like it can only send IR data, like most phones.

@HubSteven
Copy link
Owner

These two are compatible, easy to get and confirmed to be working:
https://irdroid.eu/product/usb-irda-kit/
https://irdroid.eu/product/irdroid-usb-irda-transceiver-2/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@agtbaskara @DebbyX3 @HubSteven and others