JvHidControllerClass for USB e mail notifier? lazarus / 31-LCL ---------------------------------------------------------------------- DL4OCE · 2013-03-12 13:15 Hi, I've just bought this device: http://www.geekalerts.com/u/usbwebmailnotifier.jpg (VID:PID is 1294:1320 RISO KAGAKU CORP) Now I wonder if I can control it's LEDs with Lazarus. I've found that ut's possible with Delphi, but how can I user JvHidControllerClass in Free Pascal? Or is there anything similar I can use? ---------------------------------------------------------------------- DL4OCE · 2013-03-19 13:09 Let me ask this in a different manner: How would I use the device with FreePascal? I'd have to send some bytes to the device via HID, but how can I do this? How do I enumerate USB devices to find the right one...? ---------------------------------------------------------------------- BigChimp · 2013-03-19 13:18 No idea. Supposing you're on Windows, you'd presumably use API calls if there aren't any units in Laz (which I don't know).. ---------------------------------------------------------------------- Leledumbo · 2013-03-19 16:01 QuoteHow would I use the device with FreePascal?USB devices are similar, what you have to know is what to send to which port/whatever. QuoteI'd have to send some bytes to the device via HID, but how can I do this?Normally a library and API doc should be provided to wrap low level details (I have experience with some USB dongles). But if not, welcome to the jungle. Read the datasheet, search what you have to send to activate certain functionalities. Use USB library like libusb for raw access and start experimenting... QuoteHow do I enumerate USB devices to find the right one...?If you use libusb, I think looking at the API docs you can easily guess... ---------------------------------------------------------------------- DL4OCE · 2013-04-18 17:59 Well, I have an example for python here: Code: [Select]#!/usr/bin/env python import usb import sys import time class MailNotifier: def makeData(self, color): return (color, 0, 0, 0, 0) def __init__(self): self.dev=UsbDevice(0x1294, 0x1320) self.dev.open() self.dev.handle.reset() def setColor(self, color): self.dev.handle.interruptWrite(0x02, self.makeData(color), 1000) class UsbDevice: def __init__(self, vendor_id, product_id): busses = usb.busses() self.handle = None count = 0 for bus in busses: devices = bus.devices for dev in devices: if dev.idVendor==vendor_id and dev.idProduct==product_id: self.dev = dev self.conf = self.dev.configurations[0] self.intf = self.conf.interfaces[0][0] self.endpoints = [] for endpoint in self.intf.endpoints: self.endpoints.append(endpoint) return sys.stderr.write("No mail notifier found\n") def open(self): if self.handle: self.handle = None try: self.handle = self.dev.open() self.handle.detachKernelDriver(0) self.handle.detachKernelDriver(1) self.handle.setConfiguration(self.conf) self.handle.claimInterface(self.intf) self.handle.setAltInterface(self.intf) return True except: return False def main(argv): if len(argv) != 2: sys.stderr.write("Usage : %s color_number\n" % argv[0]) else: m = MailNotifier() m.setColor(int(argv[1])) if __name__=="__main__": main(sys.argv) But I don't know how to do this in Free Pascal?! ---------------------------------------------------------------------- avra · 2013-04-19 10:09 The most simple way to change device's color would be to follow this tutorial: http://vogelchr.blogspot.com/2013/03/webmail-notifier-linux- hidraw.html If you want to code then take a look at this Lazarus HID example: http://mcuprogramming.blogspot.com/2010/12/example-in-lazarus-for- libusb.html More info: http://wiki.lazarus.freepascal.org/Hardware_Access#libusb http://libusb.sourceforge.net http://www.libusb.org http://www.lazarus.freepascal.org/index.php/topic,13000.msg67843.html# msg67843 http://www.lazarus.freepascal.org/index.php/topic,13182.msg72638.html# msg72638 http://www.lazarus.freepascal.org/index.php/topic,15882.msg85976.html# msg85976 http://www.usb.org/developers/hidpage http://www.usb.org/developers/hidpage#HID%20Descriptor%20Tool http://www.usb.org/developers/tools/ You can examine USB device properties and analyse communication with some software USB protocol sniffer (there are free and commercial ones), or with some hardware sniffer (expensive).