Hi all,
I am using a GSM modem and a friend of mine is helping me with the solution... but he doesn't have the modem
so he couldn't test it.. in my side, when I click the Read GSM button the system crashes or hangs for a very
long time before telling it's not responding!!
Please see the code below and I would appreciate any explanation!
B4X:
Sub btnRead_Action
'Read string from GSM modem
Dim iStream As InputStream
iStream = sp.GetInputStream
Dim buffer() As Byte
Dim count As Int = iStream.ReadBytes(buffer,0,buffer.Length)
TextArea1.text = BytesToString(buffer,0,buffer.Length,"UTF-8")
End Sub
This is exactly why you need to use AsyncStreams. It will never hang your app. Your current code will hang the main thread until there is at least one byte available.