Hi,
with the Web Serial API it is possible to connect to serial devices from the webbrowser (Chrome only).
There are examples like this terminal programm: serialterminal
I wonder if it would be possible to write a similar programm in B4J and transpile it to Javascript using BANano?
Any recommendations highly appreciated.
I looked at the 'serial terminal' code and maybe it would be possible to connect to the banana, but no one will do it unless they want to use it themselves. I guess no one has time for that.
@dk9uv Here is something to get you started. I have no idea what works or not as I do not have any compatible serial device to test it. I added a OPN2001 scanner (which has its own Serial to USB driver) and I know this driver does not work well with the Web Serial API. I can connect, but that is about it. The OPN2001 does not allow you to do anything more, but maybe you have a serial device that does allow other things.
It is not used in this project. I don't get this error so maybe try the sync button in the files tab.
I see, change it to:
B4X:
Sub MenuList_Click (returnName As String)
' here we can load the layout of the menu item we clicked
Select Case returnName
Case "page1"
MainPageHolder.Element.Empty
MainPageHolder.Element.LoadLayout("WebSerialPageLayout") '<--------
End Select
' and close the menu, if not always open
If MainSidebar.AlwaysOpen = False Then
MainSidebar.Close
End If
End Sub
As I said, absolutely no idea what works or not. I have nothing that uses serial. Web Serial is very experimental and I haven't found a device yet where it works.
- Does it work with the link in the first post? (the original JavaScript code).
- Do you see errors in the Chrome Developer logs?
Hi there.. I am trying to convert this code here as a start.. https://whatwebcando.today/serial.html I don't have a serial port also. :rolleyes: I have attached a BANano Project to indicate my trial, a trial and error exercise. Its BANanoObject and then some await! you can imagine! Please...
@dk9uv Here is something to get you started. I have no idea what works or not as I do not have any compatible serial device to test it. I added a OPN2001 scanner (which has its own Serial to USB driver) and I know this driver does not work well with the Web Serial API. I can connect, but that is about it. The OPN2001 does not allow you to do anything more, but maybe you have a serial device that does allow other things.
Thank you very much, great help. I successfully did the first tests. I connected a USB to RS-485 converter and can talk to a RS-485 temperature sensor (simple ASCII request response). I have to become more familiar with BANano to be able to extend the app. Future plans include Modbus support.
Chris