Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read data from USB serial device

I am trying to read data from a USB serial RFID device in Ubuntu.

The device is: https://www.sparkfun.com/products/8852

The device is recognised under Ubuntu as:

/dev/ttyUSB0

If I use programs such as 'screen' or 'minicom' when I touch an RFID tag to the reader, a unique number is shown on screen.

I want to be able to get this data through terminal. Then when I have this data process if however necessary.

My question is, how can I get the data like I see it in these programs? I would like to either write a bash or PHP script to get at the data.

Thanks

like image 215
user1814487 Avatar asked Nov 13 '22 08:11

user1814487


1 Answers

If you are going to use PHP (*nix/Windows) then you are looking for the PHP dio (Direct I/O) extension: http://php.net/manual/en/book.dio.php

From PHP manual:

PHP supports the direct io functions as described in the Posix Standard (Section 6) for performing I/O functions at a lower level than the C-Language stream I/O functions (fopen(), fread(),..). The use of the DIO functions should be considered only when direct control of a device is needed. In all other cases, the standard filesystem functions are more than adequate.

like image 144
Eugen Mihailescu Avatar answered Nov 14 '22 22:11

Eugen Mihailescu