Android Question Barcode scanner serial uart.

vdudukov

Member
Licensed User
Longtime User
Hi everyone.

I have a POS device with hardware barcode scanner on the top of device (WF360 model).

Well, in device I have an application which makes me choose Keyboard emulation or Data Input: Serial Port (/dev/scanner)

I tried everything to make a serial connection, with SerialPort and Usb serial port, but nothing happens.

I downloaded Google Serial Port Api app from Google Play, and it works fine.

So i dont know what i am doing wrong ?
 

Attachments

  • picture.png
    picture.png
    238 KB · Views: 492

picenainformatica

Active Member
Licensed User
Longtime User
I have the wide fly 360 without scanner so i cannot try it. Set as keyboard and try to use with keypress event in activity.
 
Upvote 0

picenainformatica

Active Member
Licensed User
Longtime User
serialport is a file. search forum for an example. If i remember well there is a sample with stream and serial port.
 
Upvote 0

vdudukov

Member
Licensed User
Longtime User
Now just to find solution how to make AsynStreamsText with File.ReadString("/dev/ttyMT2",""), or to synchronize scan button with File.ReadString("/dev/ttyMT2","").
 
Upvote 0

vdudukov

Member
Licensed User
Longtime User
I tried another method:

Sub button_Click
d.SetPort("/dev/ttyMT2",9600,0x2)
x.Initialize(d.InputStream,d.OutputStream,"astreams")
End Sub

Sub astreams_NewData (Buffer() As Byte)
Dim msg As String
msg = BytesToString(Buffer, 0, Buffer.Length, "UTF8")
edittext2.Text = msg
edittext2.Text = edittext2.text.Replace("�","")
edittext2.Text = edittext2.text.Replace(",","")
End Sub

now, when I press software button, i receive text like this: ��, 123456789
I tried to put timer to tick every second to receive data from barcode scanner, but it is not good. Sometimes I receive ��,��,123456789
��,123456789
123456789
is it possible to use AsyncStreamText class to receive data synchronized ?

like this example: ��, 123456789
��, 123456789
��, 123456789
 
Upvote 0

picenainformatica

Active Member
Licensed User
Longtime User
B4X:
Sub astreams_NewData (Buffer() As Byte)
Dim i as int
for i=0 to buffer.lenght-1
    log(buffer(i))
next
End Sub

To see which caracters are �
 
Upvote 0

vdudukov

Member
Licensed User
Longtime User
44
51
56
53
52
48
49
48
51
59
57

And hardware keys on left and right side cannot be identificated by Activity_KeyPress.

So I use software button

Sub button1_Click
broadcastreceiver.sendbroadcast("com.hampoo.barcodescanner")
End Sub

Then i can scan.
 
Upvote 0

picenainformatica

Active Member
Licensed User
Longtime User
Seems that the Barcode starts with 44 (comma) then you must ignore anything before character 44.
 
Upvote 0

vdudukov

Member
Licensed User
Longtime User
Well now I understand most everything.

Well my port UART ttyMT2, is file ttyMT2 in folder dev.

It is not real serial connection.
 
Upvote 0

EvgenyB4A

Active Member
Licensed User
Longtime User
I tried another method:

Sub button_Click
d.SetPort("/dev/ttyMT2",9600,0x2)
x.Initialize(d.InputStream,d.OutputStream,"astreams")
End Sub

Sub astreams_NewData (Buffer() As Byte)
Dim msg As String
msg = BytesToString(Buffer, 0, Buffer.Length, "UTF8")
edittext2.Text = msg
edittext2.Text = edittext2.text.Replace("�","")
edittext2.Text = edittext2.text.Replace(",","")
End Sub

now, when I press software button, i receive text like this: ��, 123456789
I tried to put timer to tick every second to receive data from barcode scanner, but it is not good. Sometimes I receive ��,��,123456789
��,123456789
123456789
is it possible to use AsyncStreamText class to receive data synchronized ?

like this example: ��, 123456789
��, 123456789
��, 123456789
Hi
Did you try close the app and then open it again? I tried and after opening again the app stacks on d.Setport..
 
Upvote 0
Top