Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-06

Linux USB programming using FPC

6 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

Hi guys,

I'm interested in exploring the USB interface from within Linux using FPC. I have looked at libusb and am aware of the functionality which it exposes.

I would appreciate it if someone with USB programming experience could help by pointing me to a website or documentation that reveals a bit more than just iterating through connected devices on a USB bus. A code snippet or two would be most helpful.

While I am aware that specific device drivers are required in order to access specific USB devices, code samples demonstrating reading and writing to and from a file system on USB stick would be most welcome.

Regards,
Nino

Reply by email

Henry Vermaak
to Unknown author

2009/6/15 :

Show quoted text 13 lines
Hi guys, I'm interested in exploring the USB interface from within Linux using FPC. I have looked at libusb and am aware of the functionality which it exposes. I would appreciate it if someone with USB programming experience could help by pointing me to a website or documentation that reveals a bit more than just iterating through connected devices on a USB bus. A code snippet or two would be most helpful. While I am aware that specific device drivers are required in order to access specific USB devices, code samples demonstrating reading and writing to and from a file system on USB stick would be most welcome.

the kernel already provides a driver for usb mass storage devices. this is not a trivial driver, so trying to implement that in user space is probably not what you want to do. just mount the drive somewhere and use your favourite input/output functions/syscalls to write to the filesystem.

henry

Reply by email

Johann Glaser
to Unknown author: I'm interested in exploring the USB interface from within Linux using FPC. I have looked…

Hi!

Am Montag, den 15.06.2009, 09:44 +0200 schrieb

Show quoted text 13 lines
Hi guys, I'm interested in exploring the USB interface from within Linux using FPC. I have looked at libusb and am aware of the functionality which it exposes. I would appreciate it if someone with USB programming experience could help by pointing me to a website or documentation that reveals a bit more than just iterating through connected devices on a USB bus. A code snippet or two would be most helpful. While I am aware that specific device drivers are required in order to access specific USB devices, code samples demonstrating reading and writing to and from a file system on USB stick would be most welcome.

As Henry already pointed out, file system (and block device) access of USB mass storage devices is already there in the Linux kernel.

For other kinds of devices, especially where the Linux kernel has no built in drivers, you can use libusb.

Some time ago I did header translations for it. I'll attach it (libusb.pas) plus some utilities and a class wrapper (usbutil.pas), firmware download to Cypress EZ-USB AN2131 (and related) chips (ezusb.pas), intel hex file reader (intelhex.pas), and some generic utilities (utils.pas) used by the other units. As an example of a device driver for a simple device I built, I'll attach accudraindev.pas. Unfortunately it's rather uncommented, sorry.

@FPC team: Are you interested in including the libusb header translations (and possibly the other stuff) to FPC rtl?

Bye
Hansi

Reply by email

Henry Vermaak
to Johann Glaser

2009/6/15 Johann Glaser :

@FPC team: Are you interested in including the libusb header translations (and possibly the other stuff) to FPC rtl?

I assume you mean the fpc packages. Just for info:

libusb 0.1* is not developed any more, since libusb 1.0 was released end of last year. libusb 1.0 hasn't made it into debian stable, yet, from what I can see, and with 91 pakcages depending on libusb 0.1, I guess it'll be around for a while still. There is a compatibility lib called libusb-compat that allows programs to talk to libusb 1.0 with the 0.1 api, though. libusb 1.0 supports linux and darwin at the moment.

So when adding a libusb 0.1 package, the other (newer) releases should probably be added, too.

Henry

Reply by email

Johann Glaser
to Henry Vermaak: 2009/6/15 Johann Glaser : I assume you mean the fpc packages. Just for info: libusb 0.1*…

Hi!

Henry Vermaak wrote 14 lines
2009/6/15 Johann Glaser : > > @FPC team: Are you interested in including the libusb header > translations (and possibly the other stuff) to FPC rtl? I assume you mean the fpc packages. Just for info: libusb 0.1* is not developed any more, since libusb 1.0 was released end of last year. libusb 1.0 hasn't made it into debian stable, yet, from what I can see, and with 91 pakcages depending on libusb 0.1, I guess it'll be around for a while still. There is a compatibility lib called libusb-compat that allows programs to talk to libusb 1.0 with the 0.1 api, though. libusb 1.0 supports linux and darwin at the moment.

Thanks for clarifying this, I was not aware of this rough transition.

So when adding a libusb 0.1 package, the other (newer) releases should probably be added, too.

Good idea, yes. I can do the translations in the summer (July) if requested. I'll also further improve and generalize the USB utilities stuff. All suggestions are welcome!

Thanks
Hansi

Reply by email