Hi Erel. Thanks for Liking my post and I need your help again.
I have been playing around with AsyncStreams and have had some great results. However, sometimes the usb port doesn't open properly or asks for permission and the astreams does not always activate on _Resume. It seems that the _Activate or _Resume activities are not set up properly. If I initialize the astreams for a second time during _Resume, the astreams stop working.
Can you please scan over my simplified code to see if I am setting things up wrongly. When I manage to activate it, it works great!
Many Thanks
Sub Process_Globals
....................................
Dim astreams As AsyncStreams
End Sub
Sub Globals
....................................
Dim Uy1 As Float
End Sub
Sub Activity_Create(FirstTime As Boolean)
....................................
usb.RequestPermission
usb.Open(38400)
If usb.UsbPresent <> usb.USB_NONE Then
Msgbox("USB Opened","USB Device")
Else
Msgbox("Error opening USB port","USB Device")
End If
astreams.Initialize(usb.GetInputStream, usb.GetOutputStream, "astreams")
....................................
End Sub
Sub Activity_Resume
....................................
usb.Open(38400)
....................................
End Sub
Sub Button6_Click
....................................
Dim Message As String 'trigger data stream
Message="U" 'from a
astreams.Write(Message.GetBytes("UTF8")) 'single byte
....................................
End Sub
Sub Astreams_NewData (Buffer() As Byte)
Dim y As Int
For y = 0 To Buffer.Length -1
....................................
Uy1 = Buffer(y)+128
....................................
Next
End Sub