Read/write serial data over Wlan 802.11 between mobile (MIT APP) and RS232 Gateway

Hello Guys

Can I use the Serial1 connectivity for a serial communication over Wifi?
I do not find the wifi interface, there is only Bluetooth but no Wlan.

Thank you in advance.
Roger

I don’t think so, unless you use a serial-network converter with the supported usb-serial chip or driver support for Android. But you can try my SerialOTG extension ver 1.2 that has support for byte oriented transmission over serial-otg adapters, BT and TCP, all using the same protocol. I have tested it with wlan connection from Android devices to TCP-terminal app, TCP-server app and used it for ModbusTCP communication.
You can follow the discussion in this thread:
https://community.appinventor.mit.edu/t/using-serial-with-ftdi/

The extension can be found at:

Thank you for your feedback.

That means I have to implement (over MIT APP) the SerialOTG 1.3 to get the right interface?

The extension allows you to communicate with byte/bytes without protocol, except for the implementation of ReadLine WriteLine with 7bit ASCII characters.

The serial servers that I have used are programmed to send/receive data bytes without protocol over the network, addressed to an ip/port and then convert it to a serial port.

The Modbus interface I mentioned is a separate extensions and implements Modbus TCP and RTU over Serial, BT and WIFI: se https://community.appinventor.mit.edu/t/modbusrtu-extension/

What do you need?

I am very new with MIT APP, thats why I have to ask again.
The extension you talk about its serialOTG, how can I implement this extension into the MIT APP?
So I can still use MitAPP with your extension together?
I am using the RS232 HF9624 Gateway, and I need to read/write over the App via WIFI.

Is this what you want to do?
Make an app in AI2 (Appinventor) that communicate over WIFI TC/IP with a remote serial port RS232 HF9624 Gateway?

Then you can use Appinventor-SerialOTG extension. You can also make a direct connection from your Android device with an OTG cable and an USB-Serial converter for testing with no changes in code other the selection of Serial or TCP.

If you only use 7bit ASCII character line oriented protocol, then you can use ReadLine/WriteLine.

If you want to use ModbusRTU, use the Appinventor-Modbus extension.

Any other communication protocol has to be programmed in Appinventor.

To use the extension:

Download file com.SerialOTG.aix from git (now updated to 1.2).
Import extension: Palette→Extension→import extension. Select com.SerialOTG.aix and import. Select the imported extension in Palette and drag it to the screen. Now its available in blocks view.

Just did the Installation. looks so far good, awesome, thank you.

Now, for the initialization:
SerialOTG1 initialize wifi (net: server address, dport: TCP-port)

We have to initialize only, before we can read/write to?

No, you also have to call open() after init(). You can have a look at the documentation SerialOTG_1.2.pdf and the test application SerialOTG_BT_WIFI.aia. You can use IsConnected() to see that you are connected, but you can not trust that it will detect all kinds of loss of communication, due to the nature of TCP.

One note: it is very easy to make simple application with AI2, but more complicated tasks can be hard to program with an untyped language. One example is control of bits and bytes.

Thank you, now I am able to manage the modifications.

Regards
Roger

Hello
Need some help to interpret the data type.
We send on serial 8databit with one 1stopbit. According your expl. that's a default setting?

That’s correct if you are using an USB to serial adapter.

Baud, stopbits, databits have no meaning if you are using TCP. You have to program your gateway with the serial communication parameters that you need.

(You can use the test application SerialOTG_BT_WIFI.apk for testing if you only use ASCII character communication.)

Dear Rolf @rkl099
1st of all - thanks for great com.SerialOTG.aix component - up and running is 5 minutes (device with 1bit over usb-2-serial scenario 1) but ...
Is there a way to set 2 stop bits ?
I connect to 2 types of device (one requiring 1 stop bit, other 2 stop bits) in 2 scenarios:
scenario 1: connecting to serial device (via USB-2-Serial converter)
scenario 2: connecting to device by USB using serial inside it

Just for reference, from my git account (don’t know if the request is from you) :

”Requires 38400 8N2 configuration. How can I make two stop bits?”

”This is not implemented in the extension (yet), even if its included in the Physicaloid library. Mainly because it's difficult to test.
It can be added for transmit, but it will not be tested for in the receive function.
It's easy to implement if you need it, but time consuming to test for all usb-serial adapters”

So I will add this soon. I let you know when it's ready for testing!

I can beta test it - I expect this radio m0nka to be brought to me today (although I do not know if it is scenario 1 or 2). I may also get ft717/718 but I do not have the date yet. But probably other people would be more skilled and equipped with more devices to test it.

I have added support for Physicaloid library stopbits in SerialOTG.
StopBits(n) and n=StopBits. Value n 0=>1, 1=>1.5, 2=>2 stopbits .
Please test and report what adapter you are using (or selected driver).
(Adapter type can be tested with a Linux system and terminal cmd dmesg) The extension can be found at GitHub - rkl099/Appinventor_Debug: Debug versions: SerialOTG Add support for ATTINY85+Stopbits, Modbus add 32b reg R

1 Like

Device: The m0nka (aka mcHF) arrived Tuesday night - it connects over USB cable (the device has USB connector) and has VID/PID reported by Sunny's aix as 1002/1150 (it says also 2.0 which I think is version).
Results: It works on both old version and on new with any parity - probably USB controllers negotiate any parameters (baud, parity,..).

To-Do: Yaesu FT817/818 with real serial claimed 2stop bit- I will get one of these devices with USB-2-Serial converter cable somewhere next week due to holidays - will test asap.
Thanks a lot for great plugin !

Device: Yaesu FT817 requiring 9600-38400 + 2 STOP bits.
Result: All works great ! The little problem is it works same both with 1 and 2 stop bits. I guess my app does not put stress on it enough to cause buffer overflow. Anyway, it works, it is safe to use so I'm very happy. Thanks a lot.

1 Like

Hi, can we use the SerialOtG extension also for a multiple client communication? We are going to connect 6 Serial-Gateways to one hotspot on an android device running 6 Instances based on SerialOtG extension.

best regards
Ro

If I understand it correctly, each instance is connected to a serial device.
SerilaOTG is based on a modified Pysicaloid library and was designed for a single usb-serial connection on a phone. I can see two problems with your design.

  1. I don't know if it Appinventor use shared libraries and how this works on android.
  2. There is no way to specify which usb-serial device it should use. It simply uses the first it find.

So you have to test to see what is possible to do.

hi

We have 4 separate Apps to be configured accordingly because we assign per App one IP for the WIFI connection:


As long the device with the separate Apps acts as a Hotspot Server, all the PLC devices can connect and use a separate IP (PLC-Device belongs to a separate APP on the Serial device).