Android Question USING EMBEDDED RS232 SERIAL PORT

Sganga61

Member
Licensed User
Longtime User
Hi
I need to add code to my application to use the embedded serial port (RS232) of my industrial tablet using B4A.
Following some examples found on the forum I add this simple code:

(in the global)
Dim SerialPort As AsyncStreams

(in start activity)
fo = File.OpenOutput("","/dev/ttyS0", False) '********
fi = File.OpenInput("","/dev/ttyS0")
SerialPort.Initialize(fi,fo,"astreams")

(then in the code)
Sub astreams_NewData (Buffer() As Byte)
Log(BytesToString(Buffer, 0, Buffer.Length, "UTF8"))
End Sub

Sub STESTn_Click
File.WriteString("/dev/ttyS0", "","serial comm test" & CRLF)
End Sub

-------------------

In debug mode reaching the line with '****** I get the following error and program closed:

error occured on line ......
java.io.filenotfoundexception: (dev/ttyso: open failed: EACCES (permission denied)

PS: the file ttyso already exist in the system dev/ folder


Who can help me?
 
Top