Trying to read and write to the serial port on the Raspberry Pi 3B+
Using B4J 7, jSerail library
I get the following error when I do the astream.initialize
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
splist is a list of serial ports from splist = sp.ListPorts
after the sp.Open you can see it has opened the device /dev/ttyAMA0 which is the only device it finds
You can see I tried o=sp.GetInputStream and o=sp.GetOutputStream. These don't fail but hovering over the o doesn't show anything - (should it?)
Also tried the astream.InitializePrefix but get the same error
Have run out of ideas on what to try - any ideas please?
Has anyone had success?
EDIT: After hours of trying I tried a reboot and now I see two serial ports and seem to have got rid of the error so will continue and update
Thanks
Jon
Using B4J 7, jSerail library
I get the following error when I do the astream.initialize
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
B4X:
Sub btnRead_Click
Dim s As String
Dim o As Object
If splist.Size = 1 Then
sp.Open(splist.Get(0))
sp.SetParams(115200,8,1,0)
'o=sp.GetInputStream
'o=sp.GetOutputStream
'astream.Close
astream.Initialize(sp.GetInputStream,sp.GetOutputStream,"astream")
'astream.InitializePrefix(sp.GetInputStream, True, sp.GetOutputStream, "astream")
End If
End Sub
splist is a list of serial ports from splist = sp.ListPorts
after the sp.Open you can see it has opened the device /dev/ttyAMA0 which is the only device it finds
You can see I tried o=sp.GetInputStream and o=sp.GetOutputStream. These don't fail but hovering over the o doesn't show anything - (should it?)
Also tried the astream.InitializePrefix but get the same error
Have run out of ideas on what to try - any ideas please?
Has anyone had success?
EDIT: After hours of trying I tried a reboot and now I see two serial ports and seem to have got rid of the error so will continue and update
Thanks
Jon
Last edited: