domdom Posted May 12, 2013 Report Posted May 12, 2013 Hi. I've home made tiller and I've one free analogic slot on USB Servo card. Does method exist in order that FSUIPC recognizes this input like an axis. Many thanks. Domdom
Pete Dowson Posted May 15, 2013 Report Posted May 15, 2013 I've home made tiller and I've one free analogic slot on USB Servo card. Does method exist in order that FSUIPC recognizes this input like an axis. How is this input occurring? Do you have a driver for this card? If so does it emulate a joystick, in which case it should show up as an axis in any case, or does it have an FSUIPC interface and send the data to an offset? If there's no driver, and you have to resort to reading the USB data directly, as a HID device ("Human Interface Device"), then it can be done but you'd have to resort to some plug-in programming in Lua, using the Lua com library hid functions. Regards Pete
domdom Posted May 17, 2013 Author Report Posted May 17, 2013 Many thanks Pete. It's an HID device then I will try the second method asap. Regards. Domdom.
Pete Dowson Posted May 17, 2013 Report Posted May 17, 2013 It's an HID device then I will try the second method asap. Okay. I don't know if it will help, and please don't let it put you off, but here's a Lua plug-in I did for a Cockpitsonic 737 overhead Electric Metering Panel (EMP). It's just a test program, displaying switch changes on a Lua window and displaying test patterms on the metering display. Sorry about the lack of comments (I tend to find code desribes itself better than my inane comments would), but at least it does use all the things you might need -- opening the device, reading, interpreting and writing. You may also find the HidScanner program useful -- in the Lua thread within the Download Links subforum. dev, rd, wrf, wr, init = com.openhid("Cockpitsonic", "EMP", 0)if dev == 0 then ipc.log("Could not open HID") ipc.exit()enddisplaymax = 20str2nums = string.char(0xff,0x02,0xd7,0x30,0xd0,0x45,0xc8,0x08,0xd3,0x00,0xc0, 0x7f,0x82,0x57,0xb0,0x50,0xc5,0x48,0x88,0x53,0x80,0x40, 0xff,0x02,0xd7,0x30,0xd0,0x45,0xc8,0x08,0xd3,0x00,0xc0)str3nums = string.char(0xfe,0x11,0xba,0x85,0x82,0x2b,0x42,0x41,0x9a,0x01,0x02, 0xff,0x10,0xbb,0x84,0x83,0x2a,0x43,0x40,0x9b,0x00,0x03, 0xfe,0x11,0xba,0x85,0x82,0x2b,0x42,0x41,0x9a,0x01,0x02)-- clear down the displayipc.lineDisplay("", 0)ipc.log("rd = " .. rd .. " wrf = " .. wrf .. " wr = " .. wr)com.write(dev, string.char(1,0), 2)com.write(dev, string.char(2,0xff,0xff,0xff,0xff,0xff,0xff), wr)com.write(dev, string.char(3,0xff,0xff,0xff,0xff,0xff,0xff), wr)n2 = 1n3 = 2brite = 240doinit = init and (string.byte(init,1) ~= 0)if doinit then prev1 = 255 - string.byte(init,2) prev2 = 255 - string.byte(init,3) prev3 = 255 - string.byte(init,4)else prev1 = 0xff prev2 = 0xff prev3 = 0xffendwhile 1 do ipc.sleep(500) while doinit or (com.test(dev) ~= 0) do if doinit then str = init doinit = false else str = com.read(dev,rd,rd) end -- decode val0 = string.byte(str,1) if (val0 == 1) then val1 = string.byte(str,2) val1ch = logic.Xor(val1, prev1) prev1 = val1 if val1ch ~= 0 then if logic.And(val1ch, 1) ~= 0 then if logic.And(val1, 1) ~= 0 then ipc.lineDisplay("Battery Master On", -displaymax) else ipc.lineDisplay("Battery Master Off", -displaymax) end end if logic.And(val1ch, 2) ~= 0 then if logic.And(val1, 2) ~= 0 then ipc.lineDisplay("Cab/Util On", -displaymax) else ipc.lineDisplay("Cab/Util Off", -displaymax) end end if logic.And(val1ch, 8) ~= 0 then if logic.And(val1, 8) ~= 0 then ipc.lineDisplay("Maint released", -displaymax) else ipc.lineDisplay("Maint pressed", -displaymax) end end end val2 = string.byte(str,3) val2ch = logic.Xor(val2, prev2) prev2 = val2 if val2ch ~= 0 then if logic.And(val2, 1) == 0 then ipc.lineDisplay("AC Select = Stby Pwr", -displaymax) elseif logic.And(val2, 2) == 0 then ipc.lineDisplay("AC Select = Grd Pwr", -displaymax) elseif logic.And(val2, 4) == 0 then ipc.lineDisplay("AC Select = Gen1", -displaymax) elseif logic.And(val2, 8) == 0 then ipc.lineDisplay("AC Select = APU Gen", -displaymax) elseif logic.And(val2, 16) == 0 then ipc.lineDisplay("AC Select = ???", -displaymax) elseif logic.And(val2, 32) == 0 then ipc.lineDisplay("AC Select = Test", -displaymax) elseif logic.And(val2, 64) == 0 then ipc.lineDisplay("AC Select = Inv", -displaymax) elseif logic.And(val2, 128) == 0 then ipc.lineDisplay("AC Select = Gen2", -displaymax) end end val3 = string.byte(str,4) val3ch = logic.Xor(val3, prev3) prev3 = val3 if val3ch ~= 0 then if logic.And(val3, 1) == 0 then ipc.lineDisplay("DC Select = Stby Pwr", -displaymax) elseif logic.And(val3, 2) == 0 then ipc.lineDisplay("DC Select = Bat Bus", -displaymax) elseif logic.And(val3, 4) == 0 then ipc.lineDisplay("DC Select = Bat", -displaymax) elseif logic.And(val3, 8) == 0 then ipc.lineDisplay("DC Select = Aux Bat", -displaymax) elseif logic.And(val3, 16) == 0 then ipc.lineDisplay("DC Select = Test", -displaymax) elseif logic.And(val3, 32) == 0 then ipc.lineDisplay("DC Select = TR3", -displaymax) elseif logic.And(val3, 64) == 0 then ipc.lineDisplay("DC Select = TR2", -displaymax) elseif logic.And(val3, 128) == 0 then ipc.lineDisplay("DC Select = TR1", -displaymax) end end end end com.write(dev, string.char(1,brite), wr) brite = brite - 16 if brite < 0 then brite = 240 end com.write(dev, string.char(3) .. string.sub(str2nums, n2, n2+5), wr) n2 = n2 + 1 if n2 > 22 then n2 = 1 end com.write(dev, string.char(2) .. string.sub(str3nums, n3, n3+5), wr) n3 = n3 + 1 if n3 > 22 then n3 = 1 endend[/CODE]Good luck!Pete
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now