Hi i have been trying to get the Panel PC built in comm port working, with mixed success.
the NewData sub seems to keep firing with no new data and randomly receiving the old data back in the buffer??
i have attached the log, so you can see what is happening, does anyone have any thoughts, as you can see the program is very basic, with just one button on the layout 'STESTn'.
Thanks
Stu
the NewData sub seems to keep firing with no new data and randomly receiving the old data back in the buffer??
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private xui As XUI
Dim Result As Int ' used for shell
Dim Ph As Phone ' used for shell
Dim Arh() As String ' used for shell
Dim StdOut, StdErr As StringBuilder ' used for shell
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
Dim SerialPort As AsyncStreams
Dim stream As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
stream = "/dev/ttyS1"
Dim fo As OutputStream
Dim fi As InputStream
fo = File.OpenOutput("",stream, True) '********
fi = File.OpenInput("",stream)
SerialPort.Initialize(fi,fo,"astreams")
StdOut.Initialize ' initialize string builder for StdOut
StdErr.Initialize ' initialize string builder for StdErr
Result = Ph.Shell("stty -F " & stream & " 4800 cs8 -cstopb -parenb",Arh, StdOut, StdErr) ' set 4800,N,8,1
Log("Result " & Result)
End If
Activity.LoadLayout("Layout")
End Sub
Sub astreams_NewData (Buffer() As Byte)
Dim curTime As String = $"[$datetime{DateTime.Now}]"$
Log("{" & curTime & "}" & BytesToString(Buffer, 0, Buffer.Length, "UTF8"))
End Sub
Sub STESTn_Click
Dim curTime As String = $"[$datetime{DateTime.Now}]"$
File.WriteString(stream, "",curTime & " - serial comm test" & CRLF)
Log("Test Sent")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
i have attached the log, so you can see what is happening, does anyone have any thoughts, as you can see the program is very basic, with just one button on the layout 'STESTn'.
Thanks
Stu