W wolvo66 Member Licensed User Longtime User Apr 24, 2013 #1 Hi, I’m trying to connect to an Arduino compatible via usb, the connection from Android to the Arduino works ok, but nothing in return direction – it even seems that the usb connection is blocking the Arduino from transmitting as the tx led isn’t lighting. My Arduino code is just looping back what it receives. When I connect the Arduino to PC and use hyperterminal everything works fine, tx led lights and messages are sent from Arduino to PC. I’m using a Nexus 7 with an on-the-go cable and AGraham’s latest usb serial library v2.3 I’ve experimented with setting driver and pid based on my configuration, but that didn’t seem to help e.g. Code: Copy If (usb.HasPermission) Then usb.SetCustomDevice(usb.DRIVER_CDCACM, 0x2341,0x8036) Log(usb.DeviceInfo) I have a usb tracer, but I’m not sure what to look for e.g. I can see some differences in endpoints compared to PC case. Any suggestions what I could try? - Thanks!
Hi, I’m trying to connect to an Arduino compatible via usb, the connection from Android to the Arduino works ok, but nothing in return direction – it even seems that the usb connection is blocking the Arduino from transmitting as the tx led isn’t lighting. My Arduino code is just looping back what it receives. When I connect the Arduino to PC and use hyperterminal everything works fine, tx led lights and messages are sent from Arduino to PC. I’m using a Nexus 7 with an on-the-go cable and AGraham’s latest usb serial library v2.3 I’ve experimented with setting driver and pid based on my configuration, but that didn’t seem to help e.g. Code: Copy If (usb.HasPermission) Then usb.SetCustomDevice(usb.DRIVER_CDCACM, 0x2341,0x8036) Log(usb.DeviceInfo) I have a usb tracer, but I’m not sure what to look for e.g. I can see some differences in endpoints compared to PC case. Any suggestions what I could try? - Thanks!
agraham Expert Licensed User Longtime User Apr 24, 2013 #2 Those IDs are for the Arduino Leonardo and are already recognised by the CDC ACM driver so the author of the driver thought that it would work. However! from arduino.cc The Leonardo differs from all preceding boards in that the ATmega32u4 has built-in USB communication, eliminating the need for a secondary processor. This allows the Leonardo to appear to a connected computer as a mouse and keyboard, in addition to a virtual (CDC) serial / COM port. Click to expand... I suspect that the mouse and keyboard capability may be affecting getting the right endpoints. If you can do a DeviceInfo on it and post the results there I'll take a look to see if there is anything I could do. Upvote 0
Those IDs are for the Arduino Leonardo and are already recognised by the CDC ACM driver so the author of the driver thought that it would work. However! from arduino.cc The Leonardo differs from all preceding boards in that the ATmega32u4 has built-in USB communication, eliminating the need for a secondary processor. This allows the Leonardo to appear to a connected computer as a mouse and keyboard, in addition to a virtual (CDC) serial / COM port. Click to expand... I suspect that the mouse and keyboard capability may be affecting getting the right endpoints. If you can do a DeviceInfo on it and post the results there I'll take a look to see if there is anything I could do.
W wolvo66 Member Licensed User Longtime User Apr 24, 2013 #3 Thanks for the reply Yes... I think that may be it, when the Leonardo is connected the Android keyboard is blocked from opening Device info trace attached... yes it's recognized as a HUD. So maybe I have to hack it from the Arduino end that it is recognized as something else than a Leonardo? Or is there some other possible solution? Thanks again for you help! Attachments usbDeviceInfo.txt usbDeviceInfo.txt 1.4 KB · Views: 749 Upvote 0
Thanks for the reply Yes... I think that may be it, when the Leonardo is connected the Android keyboard is blocked from opening Device info trace attached... yes it's recognized as a HUD. So maybe I have to hack it from the Arduino end that it is recognized as something else than a Leonardo? Or is there some other possible solution? Thanks again for you help!
agraham Expert Licensed User Longtime User Apr 24, 2013 #4 Android claims HID devices so to use it would need a change to the Arduino to stop it being recognised as an HID device which I guess would mean suppressing the HID interface details. Other than that it looks like it should work, or to put it another way, if it doesn't work I can't see what I could change to make it work. Upvote 0
Android claims HID devices so to use it would need a change to the Arduino to stop it being recognised as an HID device which I guess would mean suppressing the HID interface details. Other than that it looks like it should work, or to put it another way, if it doesn't work I can't see what I could change to make it work.
W wolvo66 Member Licensed User Longtime User May 8, 2013 #5 Thanks for the guidance agraham I managed to suppress the HID in the Arduino as you proposed (I can see from the device info that it is not there and the Android keyboard opens - which it didn't before). SO some progress! But still the Android doesn't receive any messages back from the Arduino. Pid and vid are as Leonardo 0x2341,0x8036, so I guess this line of code is still redundant: usb.SetCustomDevice(usb.DRIVER_CDCACM, 0x2341,0x8036) Then I tried changing the pid and vid in the Arduino to some random numbers e.g. 0x1111 and 0x1111 Now the Android doesn't recognize that a USB device is connected. Still it works great with an Arduino with FTD. Any idea what I could try next? Upvote 0
Thanks for the guidance agraham I managed to suppress the HID in the Arduino as you proposed (I can see from the device info that it is not there and the Android keyboard opens - which it didn't before). SO some progress! But still the Android doesn't receive any messages back from the Arduino. Pid and vid are as Leonardo 0x2341,0x8036, so I guess this line of code is still redundant: usb.SetCustomDevice(usb.DRIVER_CDCACM, 0x2341,0x8036) Then I tried changing the pid and vid in the Arduino to some random numbers e.g. 0x1111 and 0x1111 Now the Android doesn't recognize that a USB device is connected. Still it works great with an Arduino with FTD. Any idea what I could try next?
agraham Expert Licensed User Longtime User May 8, 2013 #6 As you say SetCustomDevice should be redundant as the library will recognise those IDs. If it is still working in only one direction then there is nothing more I can suggest to try as it looks like the Leonardo is too different from the other Arduinos. Upvote 0
As you say SetCustomDevice should be redundant as the library will recognise those IDs. If it is still working in only one direction then there is nothing more I can suggest to try as it looks like the Leonardo is too different from the other Arduinos.
P Peter Gould Member Licensed User Longtime User Mar 1, 2014 #7 Thanks for the information so far. I've gotten to the same point as wolvo66. I can communicate with the Arduino Leonardo chip (Atmega32U4) but I cannot receive data back. This seems particularly strange since my understanding is that USB hardware is bi-directional. It uses the same conductors to send and receive data. Why would it work in only one direction with Android? Anyone made any additional progress on this? ***A little more on this**** I also found that none of the serial monitor programs (e.g., Termite) on my Windows machine will receive data from the Leonardo but work with the Uno. So it's not only Android. But the Arduino built-in serial monitor does work. Next step is to figure out what Arduino is doing differently. Last edited: Mar 1, 2014 Upvote 0
Thanks for the information so far. I've gotten to the same point as wolvo66. I can communicate with the Arduino Leonardo chip (Atmega32U4) but I cannot receive data back. This seems particularly strange since my understanding is that USB hardware is bi-directional. It uses the same conductors to send and receive data. Why would it work in only one direction with Android? Anyone made any additional progress on this? ***A little more on this**** I also found that none of the serial monitor programs (e.g., Termite) on my Windows machine will receive data from the Leonardo but work with the Uno. So it's not only Android. But the Arduino built-in serial monitor does work. Next step is to figure out what Arduino is doing differently.
P Peter Gould Member Licensed User Longtime User Mar 2, 2014 #8 SOLVED I got two-way communication with a Leonardo board (actually a variant from my company www.olympiacircuits.com that uses the same ATMega 32U4 chip). The issue seems to be that a ready-to-send signal is needed somewhere in the virtual com port. After making the connection with the device you need to set the RTS signal to True. Here's a code snippet based on the USBSerialDemo in agraham's usbSerialV2.3. ' within Sub btnOpen_Click make the USB connection and call the sub setRTS If dev <> usb.USB_NONE Then Log("Connected successfully!") btnOpen.Enabled = False btnClose.Enabled = True btnSend.Enabled = True setRTS astreams.Initialize(usb.GetInputStream, usb.GetOutputStream, "astreams") Else 'The sub Sub setRTS Dim R As Reflector R.Target = usb R.Target = R.getField("driver") R.RunMethod2("setRTS", True, "java.lang.boolean") End Sub Cool. Upvote 0
SOLVED I got two-way communication with a Leonardo board (actually a variant from my company www.olympiacircuits.com that uses the same ATMega 32U4 chip). The issue seems to be that a ready-to-send signal is needed somewhere in the virtual com port. After making the connection with the device you need to set the RTS signal to True. Here's a code snippet based on the USBSerialDemo in agraham's usbSerialV2.3. ' within Sub btnOpen_Click make the USB connection and call the sub setRTS If dev <> usb.USB_NONE Then Log("Connected successfully!") btnOpen.Enabled = False btnClose.Enabled = True btnSend.Enabled = True setRTS astreams.Initialize(usb.GetInputStream, usb.GetOutputStream, "astreams") Else 'The sub Sub setRTS Dim R As Reflector R.Target = usb R.Target = R.getField("driver") R.RunMethod2("setRTS", True, "java.lang.boolean") End Sub Cool.