[Gambas-user] [Gambas 2.21] Read data from usb port.
l k
lknetpl at ...626...
Thu Sep 8 23:54:45 CEST 2011
Hi, I'm writing a program to support GPSa logger. The program
correctly handles reading data from the GPS device via bluetooth. But
when I try to read data through USB is unfortunately the program does
not receive anything. And here I am in the place because I do not know
if it's my fault configuration (maybe more-capable port control
settings) or the fault lies with the Lubuntu (and maybe my laptop?).
By the console command: cat / dev/ttyUSB0 I get the whole sequence of
NMEA data from GPS devices. My program connects to the USB port but it
does not get any data. I removed the code limits the size of data
downloaded. It did not help. Reading from / dev/rfcomm0 (bluetooth)
works perfectly. Maybe someone has an idea where I could deal with it.
Below the code to connect with the port and receive data:
PUBLIC SUB button_polacz_Click()
WITH SerialPort1
.PortName = Trim(tbPortName.Text)
.Speed = vb_baudrate.Value
END WITH
IF SerialPort1.Status = 0 THEN
SerialPort1.Open
Timer1.Delay = vb_timerdelay.Value
Timer1.Start
status_portu()
Timer2.Start
button_polacz.Enabled = FALSE
Button1.Enabled = TRUE
ENDIF
CATCH
message.Error((Error.Code) & (Error.text) & (Error.Where))
END
PUBLIC SUB odbierz_dane()
SLEEP 0.025
dane_port = ""
READ #SerialPort1, dane_port, Lof(SerialPort1)
PRINT dane_port
IF dane_port <> "" AND Len(dane_port) > 300 AND Left$(dane_port,
1) = "$" THEN
rozdziel_dane()
ENDIF
CATCH
PRINT (Error.Code) & (Error.text) & (Error.Where)
END
More information about the User
mailing list