Sub AStream_NewData (Buffer() As Byte)
Dim s As String = BytesToString(Buffer, 0, Buffer.Length, "ASCII")
LogMessage(s)
End Sub
Sub LogMessage(Msg As String)
lblScale.Text = Msg.Trim
End Sub
Private ast As AsyncStreamsText
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private sp As Serial
'Private astream As AsyncStreams
Private ast As AsyncStreamsText
Dim oldMsg As String = ""
Dim lblScale As Label
Private lblLbs As Label
Private txtHidden As TextField
Private Timer1 As Timer
Private Timer2 As Timer
Private lblResponse As Label
Private lblScanner As Label
Private lblErrorResponse As Label
Private lblWaiting As Label
End Sub
Private Sub astreams_NewData (Buffer() As Byte)
Dim newDataStart As Int = sb.Length
sb.Append(BytesToString(Buffer, 0, Buffer.Length, charset))
Dim s As String = sb.ToString
'Log("s = " & s)
Dim start As Int = 0
For i = newDataStart To s.Length - 1
Dim c As Char = s.CharAt(i)
If i = 0 AND c = Chr(10) Then '\n...
start = 1 'might be a broken end of line character
Continue
End If
If c = Chr(10) Then '\n
CallSubDelayed2(mTarget, mEventName & "_NewText", s.SubString2(start, i))
start = i + 1
Else If c = Chr(13) Then '\r
CallSubDelayed2(mTarget, mEventName & "_NewText", s.SubString2(start, i))
If i < s.Length - 1 AND s.CharAt(i + 1) = Chr(10) Then '\r\n
i = i + 1
End If
start = i + 1
End If
Next
Main.LogMessage(s)
Log("s = " & s)
If start > 0 Then sb.Remove(0, start)
End Sub
Sub LogMessage(Msg As String)
lblScale.Text = Msg.Trim
End Sub
CallSubDelayed2(mTarget, mEventName & "_NewText", s.SubString2(start, i))
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.3
0
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
5.30
java.lang.InterruptedException: sleep interrupted
at java.lang.Thread.sleep(Native Method)
at anywheresoftware.b4j.serial.Serial$1.read(Serial.java:122)
at anywheresoftware.b4j.serial.Serial$1.read(Serial.java:116)
at anywheresoftware.b4a.randomaccessfile.AsyncStreams$AIN.run(AsyncStreams.java:184)
at java.lang.Thread.run(Thread.java:722)
Restarting Serial Connection 02/06/2014 12:33:20
Sub Process_Globals
Private ast As AsyncStreamsText
Private usb As UsbSerial
End Sub
Sub Globals
"YOUR GLOBALS DATA"
Dim d As double
Dim pw As PhoneWakeState' keep alive (add Phone Lib and RandomAccessFile library( for asyncstreams lib))
End Sub
Sub Activity_Create(FirstTime As Boolean)
Actiivity.LoadLayout("1")
If usb.UsbPresent = usb.USB_NONE Then
Log("Msgbox - no device")
Msgbox("No USB device or accessory detected!")
Log("Msgbox - returned")
Return
End If
Log("Checking permission")
If (usb.HasPermission) Then
usb.SetParameters(9600,8,1,0)
usb.UsbTimeout = 1000
Dim dev As Int
dev = usb.Open(9600)
If dev<> usb.USB_NONE Then
Log("Connected Successfully")
If ast.IsInitialized Then ast.Close
ast.Initialize(Me,"astreams",usb.GetInputStream,usb.GetOutStream)
Else
Log("Error opening USB port")
End If
Else
usb.RequestPermission
Flush.Enabled=True
Flush.Visible=True
End If
End Sub
Sub astreams_NewText(Text As String)
Log(Text)
Dim msg As String
d = NumberFormat2((msg),0,0,0,False)
End Sub
Sub ast_Terminated
Log("Terminated")
ast.Close
End Sub
Sub Activity_Resume
pw_KeepAlive(True)
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
You can ignore it.Anyway to avoid the error - or is it inconsequential ?
Program started.
Restarting Serial Connection 02/06/2014 12:33:20
Restarting Serial Connection 02/06/2014 12:33:20
Restarting Serial Connection 02/06/2014 13:00:35
Restarting Serial Connection 02/06/2014 13:51:33
Restarting Serial Connection 02/06/2014 14:10:24
Restarting Serial Connection 02/06/2014 14:41:05
Restarting Serial Connection 02/06/2014 15:23:58
Restarting Serial Connection 02/06/2014 15:54:08
Restarting Serial Connection 02/06/2014 17:44:56
Restarting Serial Connection 02/06/2014 18:24:53
Restarting Serial Connection 02/06/2014 19:12:45
Restarting Serial Connection 02/06/2014 19:12:45
Restarting Serial Connection 02/06/2014 19:17:55
Restarting Serial Connection 02/06/2014 19:44:49
Restarting Serial Connection 02/06/2014 20:20:34
Restarting Serial Connection 02/06/2014 20:39:23
Restarting Serial Connection 02/06/2014 21:20:10
Restarting Serial Connection 02/06/2014 21:41:01
Restarting Serial Connection 02/06/2014 22:20:48
Restarting Serial Connection 02/06/2014 23:00:14
Restarting Serial Connection 02/06/2014 23:20:54
Restarting Serial Connection 02/06/2014 23:57:21
Restarting Serial Connection 02/07/2014 00:30:36
Restarting Serial Connection 02/07/2014 00:50:12
Restarting Serial Connection 02/07/2014 01:09:52
Restarting Serial Connection 02/07/2014 01:28:28
Restarting Serial Connection 02/07/2014 01:42:53
Restarting Serial Connection 02/07/2014 02:07:38
Restarting Serial Connection 02/07/2014 02:26:33
Restarting Serial Connection 02/07/2014 03:23:24
Restarting Serial Connection 02/07/2014 03:43:49
Restarting Serial Connection 02/07/2014 04:01:49
Restarting Serial Connection 02/07/2014 04:25:26
Restarting Serial Connection 02/07/2014 04:53:42
Restarting Serial Connection 02/07/2014 05:09:11
Restarting Serial Connection 02/07/2014 05:34:12
Restarting Serial Connection 02/07/2014 06:20:17
Restarting Serial Connection 02/07/2014 07:08:25
Restarting Serial Connection 02/07/2014 07:55:40
Restarting Serial Connection 02/07/2014 08:40:39
Restarting Serial Connection 02/07/2014 09:11:22
Private Sub astreams_NewData (Buffer() As Byte)
Dim newDataStart As Int = sb.Length
'Log ("newdatastart = " & newDataStart)
sb.Append(BytesToString(Buffer, 0, Buffer.Length, charset))
Dim s As String = sb.ToString
'Log("length of s = " & s.Length)
Dim start As Int = 0
For i = newDataStart To s.Length - 1
Dim c As Char = s.CharAt(i)
If i = 0 AND c = Chr(10) Then '\n...
start = 1 'might be a broken end of line character
Continue
End If
If c = Chr(10) Then '\n
CallSubDelayed2(mTarget, mEventName & "_NewText", s.SubString2(start, i))
start = i + 1
Else If c = Chr(13) Then '\r
CallSubDelayed2(mTarget, mEventName & "_NewText", s.SubString2(start, i))
If i < s.Length - 1 AND s.CharAt(i + 1) = Chr(10) Then '\r\n
i = i + 1
End If
start = i + 1
End If
Next
Main.LogMessage(s)
'Log("scl = " & sb)
If start > 0 Then sb.Remove(0, start)
End Sub
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?