Selection of driver with USBDriver must be done before open
it does not work !
Hi Rolf. I remember that the Serial component was supposed to be updated with a new library. Did it come to fruition?
No, I have updated the Physicaloid library to make it work. Also done some refactoring to make it work together with the Physicaloid library included in MIT Appinventor.
I don't have access to this board, so I can't answer in detail.
Are you using the USB-C port for communication?
Do you have to do anything in the Arduino code to enable serial communication?
Are baudrate etc. the same for both boards?
What is the status after "open" in AI code (open,not open) or return value from the "open"?
Can you use the serial terminal app for communication?
Below are the steps performed:
Command--> USBdriver:(1)
results:
connected: false
isopen:false
Command--> initialize
results:
connected:false
isopen:false
Command--> SerialOTG open
results:
connected:true
isopen:true
Command--> 1)write data
results:
connected:true
isopen:true
Command--> 2)write data
results:
connected: true
èopen: true
I'm seeing an error
error 3209: error writing data to serial
I want to point out that the program on the Arduino is written correctly (I used a simple program for serial communication for Android "Serial USB Terminal").
P.S.
I use an sbc odroid and android version 9
You are writing that you use an odroid. Is this the ESP32 car that is working?
What serial connector are you using on the Giga?
Can you show us the relevant ai2 blocks?
Also read the driver name after Open() with DriverName() and put it in a label, so we can see what driver is selected.
Since it's not clear what serial-USB the Giga emulate or uses, you can try to select 'USDriver 1-5. This is normal.y selected by the VID/PID pair but it's not included in the extension.
OK, you are probably using an Odroid with android 8, and no phone for this test.
Is this setup the same that works wit ESP32?
The same USB port on the Odroid?
Connected to what port on the Giga?
The Serial USB terminal can probably give some device information about the connected device
I use the same configuration with esp32 and it worked. I'm connected to the USB-C port.
What information are we looking for?
Any information that helps to identify the problem.
What does work, what does not work. What is the configuration with ESP32. What is the configuration with the GIGA. Any USB-OTG adapters etc.
Hi rkl099
I think I found a bug on one of your block.
I put your call SerialOTG .Open block on a button.
I notice that, when I first click it, it opens correctly. But when I click the same button again, it closes the connection (behaving like .Close when clicked for the 2nd time)
and not only that, when that happens, even if I click open again, or i click close then click open, it just won't open the serial ever again, unless I close and reopen the app.
could you please fix this? it suppose to serve only as serial opener right? no mater how many times it is called.
I use this verison of extension.
com.SerialOTG.aix (189.4 KB)
The built-in component serial will probably behave in the same way. Try test with IsOpen() before you try to open the serial connection.
no it doesn't. before this i'm using the built in serial blocks. the only reason i'm switching is because the built in blocks doesn't have the block to check whether there is 'byte to read' before actually 'reading the data', causing me to get null or weird characters as explained in this topic,
therefore, i'm switching to your extension and it works excellently (i could also remove some blocks to deal with the "\n" that i get from using the built in serial component to read) but only this small weird .Open issue cause problem. I could actually deal with it by using if then blocks like so but I think if it can be fixed, the extra blocks just not necessarily needed.
OK, I will put it on the to do list.
Dear you!
How much I dug through to at least light the Arduino bulb! Thank you!
Please send me a link to the latest release of the extension!
The latest version of SerialOTG extension:
Release 1.5, GitHub - rkl099/Appinventor-SerialOTG: Appinventor extension SerialOTG with BT/WIFI client/server support, examples of apps and Arduino code, ver 1.5
1.5.1 adds improved FTDI write speed, GitHub - rkl099/Appinventor_Debug: Debug versions: SerialOTG, Modbus and test programs (Note: can be changed any time). Updated to 1.5.1
Dear Rolf @rkl099,
Appinventor-SerialOTG is a fantastic extension - thanks a lot !
I've recently run into 2 radios (IC705, X6100) that expose serial port on USB as 2nd device (CDC).
Would it be possible to allow to choose serial port at initialisation/before opening port ?
best rgds
Kuba, SP5NZF
This is a part of the code that i have not reviewed yet. I don't have the opportunity to do it know, but i will put the src Appinventor1.5b on github.
Thanks. I'll see if it is within my reach
Dear Rolf,
thanks a lot again for your continued support and for uploading source codes.
It took me a while but I've found that it is hidden very low in UsbCdcConnection.java class of package com.physicaloid_ai.lib.usb;
There is method:
public boolean open(int vid, int pid ) {
return open( vid, pid, false, 0);
}
And it calls another method open( vid, pid, false, 0) - now with expected channel being hardcoded to 0.
This one in turn iterates until it finds that channel. For reasonable maintability, I propose to modify just this one class, not the whole stack.
Do you think the following would work:
- In UsbCdcConnection class add a static property and a setter for it:
private static int serialChannel = 0; public static void setChannel(int channel) { serialChannel = channel; }
- In UsbCdcConnection class modify open method to use serialChannel not zero:
public boolean open(int vid, int pid ) {
return open( vid, pid, false, serialChannel); // was serialChannel instead of 0
}
- In the SerialOTG.java, add a property Channel (as you did with baud, pariti, stop...) with default value 0 and a setter that would execute static setter on the class UsbCdcConnection: UsbCdcConnection.setChannel(Channel);
Unfortunatelly I don't have knowledge (nor environment which boils down to knowledge again) to test it and send you these 2 class changed and a compiled aix ready-to-use.
Of course, I will be glad to test it right away !
Do you think it would work and you could look into it one day?
Thanks a lot again for support and good luck on your current projects.