0

I want to write data to USB port using C in Linux.

Basically, I want to read data from a file and send to USB port, where I will receive from my target board.

Can any one suggest how to do this successfully or any application for this?

Kevin Panko
  • 8,356
  • 19
  • 50
  • 61
user3095102
  • 29
  • 1
  • 4
  • If you don't need for high bitrates, consider using HID device, which is widely supported. You haven't specified what exactly is the "target board", but there are some implementations of HID for different microcontrollers. Then, you will not need for any special driver on the host side, since HID devices are supported everywhere. – Dmitry Frank Jan 10 '14 at 13:51
  • I am using Serial Communication Only, Since i can't able to connect RS232 cable to my laptop, i used usb to rs232 converter. Earlier i used Windows Comm Operator(like Hyperterminal). I could able to send a data from that. Since i want to read from a file and Send that Data serially, i am going with linux. So can u suggest me according to my Application – user3095102 Jan 10 '14 at 14:25
  • @unwind That question is about Windows, not Linux. – Kevin Panko Jan 10 '14 at 15:03
  • @Kevin, I told Earlier i used that in Windows. But now i want use in linux – user3095102 Jan 10 '14 at 15:37
  • Just because the OP said "serially" doesn't actually mean he is talking about a COM port. Please tell us exactly what device you are trying to talk to and provide the output of `lsusb -v` so we can see the descriptors. Does it create a `/dev/tty*` entry when you plug it in? – David Grayson Jan 12 '14 at 19:00

1 Answers1

1

You may use libusb library for this. Take a look at: https://libusb.info/

However you need to know something about USB protocol. USB is not like serial ports where you send raw data on one side and receive them on the other one. You need to know how USB works.

Sarkis
  • 303
  • 2
  • 12
user2699113
  • 4,262
  • 3
  • 25
  • 43
  • I am using Serial Communication Only, Since i can't able to connect RS232 cable to my laptop, i used usb to rs232 converter. Earlier i used Windows Comm Operator(like Hyperterminal). I could able to send a data from that. Since i want to read from a file and Send that Data serially, i am going with linux. So suggest me according to my Application – user3095102 Jan 10 '14 at 14:24
  • @user3095102 Suggest putting the "I am using Serial Communication Only" comment in your post. Effectively then you have a virtual comport and not a USB issue. Check-out comport applications. – chux - Reinstate Monica Jan 10 '14 at 15:34