B4J Question BANano and Web Serial API

dk9uv

Member
Licensed User
Longtime User
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.

Chris
 

MichalK73

Well-Known Member
Licensed User
Longtime User
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.
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
@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.

I would appreciate your feedback!


Alwaysbusy
 
Upvote 0

GMan

Well-Known Member
Licensed User
Longtime User
BananoSkeleton is missing ?
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
Upvote 0

GMan

Well-Known Member
Licensed User
Longtime User
Got it, but get an error when compiling
B4X:
MainPageHolder.Element.LoadLayout("WelcomePageLayout")
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
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
 
Upvote 0

GMan

Well-Known Member
Licensed User
Longtime User
Did that already ;-)
Uploaded on my external webserver, works fo far....but: i have an ARDUINO Nano pugged in (COM19) whis is not shown.

Did i miss something ?
 
Upvote 0

GMan

Well-Known Member
Licensed User
Longtime User
Yeah, its local connected an i have a valid certificate,too
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
- Does it work with the link in the first post? (the original JavaScript code).
- Do you see errors in the Chrome Developer logs?
+ what baudRate do you use? You may have also set stuff like the dataBits, parity and so on required by the Arduino.

If it does not work with the link in the first post, then it will definitely not work with the BANano version.
 
Upvote 0

GMan

Well-Known Member
Licensed User
Longtime User
Now used another NANO and now it works...can received text from NANO serialport ?
 
Upvote 0

GMan

Well-Known Member
Licensed User
Longtime User
1681903529245.png
 
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
Thank you so much for this, I will just add this previous question here so that we have related content together.

 
Upvote 0

dk9uv

Member
Licensed User
Longtime User
@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.

I would appreciate your feedback!


Alwaysbusy
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
 
Upvote 0
Top