Results 1 to 8 of 8

Thread: HID Transport Example script

  1. #1
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    12,257

    Default HID Transport Example script

    By popular demand here is an example of a HID transport. Note that we are still in Alpha stage meaning that stuff will change. Most notable we will be adding a wrapper class around the transport system to make it easier to write code that can talk any of the protocols without change.

    Code:
    function hid_cb(a,b)
    
    	if ( a ) then
    		print(math.formatbytes(a),b)
    		-- do something smart with the data coming in here
    		-- remove the print line above when done analyzing the protocol.
    	else
    		print(b)
    	end
    
    end
    
    -- print all attached HID devices.
    table.print(transport.support.usbhid.ListDevices())
    
    -- create a HID transport channel.
    hid = transport.New(transport.constants.transport.USBHID)
    -- HID devices always prepend a report ID number, for most this is unimportant, but you might need it.
    hid:StripReportID(false)	
    -- Set the CALLBACK method to read the incoming data.
    hid:Callback(transport.constants.parser.STREAM, hid_cb)
    -- Open the actually channel to the HID device
    -- You'll need to have enough of the parameters below to uniquely identify the
    -- device.
    -- Open ( <VendorID>, <ProductID>, <Manufacterer>, <Serial Number>, <Device Name>)
    -- Any of those parameters can be 'nil', which means match any device.
    print(hid:Open(1151,3233,nil,nil,nil))
    Ron
    No support through PM

  2. #2
    Join Date
    Jul 2006
    Posts
    2

    Default

    Hi Ron,
    excuse me for the question, but where should i write this script?

    Regrads.

  3. #3
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    12,257

    Default

    You can simply put this in a script action.
    Ron
    No support through PM

  4. #4
    Join Date
    Nov 2006
    Posts
    7

    Default

    Hi Ron! Thanks for the response to the problem! If I'm using version 4 should I change to 5 Alpha to test new HID? Thanks.

  5. #5
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    12,257

    Default

    Yes, you must upgrade to G5-Alpha as this is only support there.
    Ron
    No support through PM

  6. #6
    Join Date
    Oct 2005
    Posts
    3

    Default

    Hi, I added a new action and pasted the script from your post into it and tested the action. This is the output:

    [1] = {
    ["DeviceName"] = "USB",
    ["SerialNumber"] = "",
    ["ProductID"] = 49409,
    ["Manufacturer"] = "Logitech",
    ["VendorID"] = 1133,
    },
    [2] = {
    ["DeviceName"] = "USB",
    ["SerialNumber"] = "",
    ["ProductID"] = 49409,
    ["Manufacturer"] = "Logitech",
    ["VendorID"] = 1133,
    },

    I`m testing Girder5 because I have the Logitech USB HID Remote that has 2 devices and Girder4 wasn`t able to save the x, if you remeber what I mean.

    Judging from the above output, there is still no way to make a difference between the 2

  7. #7
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    12,257

    Default

    Then I'm afraid there is nothing I can do. If logitec doesn't even bother to put in a serial number how on earth are we supposed to always open the correct one. In the USB standard there is no such thing as a fixed usb port like a com1 in the serial case.
    Ron
    No support through PM

  8. #8
    Join Date
    Oct 2005
    Posts
    3

    Default

    The point here is:
    In Girder4 with the HID Plugin, the two devices alway come up in the same order.
    There must be a way to differentiate between them. Isn't there any more info available on the HID device, or maybe the serial retrieval didn't work right? I used alpha 507 ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •