LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   how to access usb data in linux 2.4 (https://www.linuxquestions.org/questions/programming-9/how-to-access-usb-data-in-linux-2-4-a-636538/)

kevin123 04-19-2008 09:57 PM

how to access usb data in linux 2.4
 
Hi, I'm very new to Linux and a beginner in C programing. Currently I am trying to write a program for an RFID reader that connects to a USB port. The RFID reader acts as an keyboard input in that whatever is scanned is displayed as if it is typed on the keyboard. I have currently written a C code that picks up the data read in by the RFID reader. I ran this code on windowxp system and it works fine, the code executes in the cmd window and displays the numbers read in by the RFID reader. However, the problem is that I am writing this code to work for a embedded single board computer(SBC) (TS-7250). The board runs on a Linux 2.4 OS and only has terminal interface , no GUI. There is no vga output so the only way to input commands to the SBC is through the hyper terminal or telnet. Here is the problem (the reader is connected to the SBC now), when I try to program through the hyperterminal or telnet, the program doesn't know to actually get the data from the reader but expects input from the computer I am run hyperterminal or telnet from. Can anyone provide me with a solution to this? Any help would be greatly appreciately, thanks in advance.

michaelk 04-20-2008 08:30 AM

From the manual you can connect a USB mouse and keyboard so you should be able to use your RFID reader. Look at the TS-ARM users guide for the particular modules that are required or contact Technologic Systems for help.

BTW depending on what functions/API you used in your windows code may not be directly portable to linux.

kevin123 04-20-2008 02:31 PM

I've loaded all the usb, hid, and keyboard modules according to the manual they've provided. I added lines to the init.d file so that it will auto load the modules during start up. One thing I forgot to mention in the previous post is that I get a message like this when loading the modules:
usb_control/bulk_msg: timeout
input: USB HID RFIDea Keyboard on usb1:2.0

Do you know what that means?
Also does anyone know how to write a C program that can read data straight from the usb port? Thanks in advance.

michaelk 04-20-2008 05:18 PM

Quote:

input: USB HID RFIDea Keyboard on usb1:2.0
Appears to be a normal message.

Quote:

usb_control/bulk_msg: timeout
Could be a problem.

Does the RFID reader work at all?

For a good starting point look at http://www.linux-usb.org/ A generic library (libhid) exists however I do not know if it is directly portable to the ARM.

kevin123 04-20-2008 11:43 PM

yea, I tried the RFID reader on a window xp machine and pc with linux installed, they both work.

michaelk 04-21-2008 06:49 AM

To elaborate it works on a x86 linux PC but not the SBC?

kevin123 04-21-2008 06:36 PM

The program, if ran from a regular (ubuntu) linux pc or winxp pc, would work perfectly. The RFID reader is plugged into the pc in both of these cases, and the program is ran directly from the pc's. However, since the single board computer doesn't have a vga output, it is required that I use telnet or hyperterminal to access the sbc then run the program from there. However when I do it this way, the program doesn't pick up the input from the RFID reader that is connected to the single board but instead looks for input from the other PC.

The RFID reader functions like a keyboard, so whatever is read is outputted into the current window/console that is being used. (i.e if notepad is focused, the output would be displayed in notepad) So I think the problem is when the program is ran through telnet or hyperterminal, the data is read, however not to the right place and I have no idea of how to fix this. I've been reading stuff around the net to find a solution with no success.

Hope that clarifies my question :D Thanks in advance.

michaelk 04-22-2008 06:11 AM

I would contact Technologic Systems for help.

theNbomr 04-22-2008 10:27 AM

I am in no way acquainted with the device you are using, however it sounds to me that you have seized upon the essence of the problem. When you use a local console, you are using 'real' devices; the local keyboard, monitor and pointing device. Logging in through a telnet or ssh session creates a virtual (pseudo) terminal, hence the names like /dev/pts0, /dev/pts1... Your HID device(s) should be accessible through the device file /dev/console, I think. Perhaps you can achieve what you want to do by writing some code to read/write/ioctl the console device. Or perhaps your driver(s) have created a new device file. If so, you may be able to access the hardware through that interface.
Hope this makes sense. Maybe someone more intimately familiar with the device & drivers can expand on the concept.
--- rod.


All times are GMT -5. The time now is 10:42 PM.