Jump to content
The simFlight Network Forums


  • Content count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About zuby

  • Rank

Profile Information

  • Gender
  • Location
  1. I got it....Thank you very much Pete for your help and time. Sorry for this.
  2. Hello Pete, Finally the below lua code is working now :). but "str = string.char(0,49)" char function's first argument must be 0 I dont know why? it does not work when i remove 0. and also guide me where should i use com.close(handle)? because i will use com.write function into offset event. if i use com.close after event then i need to reopen hid device. Under of Thanks for your help and time. local USB_DEVICE_VID = 0x1234 local USB_DEVICE_PID = 0x0001 Device = 0 -- Multiple devices of the same name need increasing Device numbers. Logging = false Report = 0 -- I *think* all joystick types use Input Report 0 dev, rd, wrf, wr, init = com.openhid(USB_DEVICE_VID, USB_DEVICE_PID, Device, Report) if dev == 0 then ipc.log("Could not open HID") ipc.exit() end local str = "" str = string.char(0,49) n = com.write(dev,str) ipc.log("return value = " .. n) com.close(dev)
  3. pete i tried that code but i'm not receiving values into my device..i don't know why?...also i showed you ipc log of that code.
  4. it means the code below is right for hid device? Vendor = 0x1234 Product = 0x0001 Device = 0 Report = 0 dev, rd, wrf, wr, init = com.openhid(Vendor, Product, Device, Report) if dev == 0 then ipc.log("Could not open HID") ipc.exit() end -- Finish HID Connect function call_speed (offset, value) com.write(dev,tostring(value), wr) end event.offset (0x07E2, "UW", "call_speed") -- aircraft speed
  5. Thanks for your reply Pete. I understood that how to write data to COM3 port....but I want to write data to HID Device. but how? I dont know. I think I can not use com.write for HID device. right?
  6. The purpose to show this library is that you can understand my problem easily...there is a proper documentation for luahidapi. Whereas how to use com.write with HID, there is no example file or documentation to use that function. Could you give me HID code example for com.write. or how do i use com.write for HID? yes the id ownded by "Technical Corp" but I'm using default HID example program (that has 0x1234 VID) of mikroc. Thanks for your reply.
  7. Thanks Pete for your response. I did not know that. thanks for your information. Here is the luahidapi library link: https://github.com/ynezz/luahidapi here is the working code of luahidapi...I copied luahidapi.dll into "Modules/lua", also copied hidapi.dll and lua51.dll into "Modules/dll" folder local hid = require "luahidapi" local sfmt, sbyte, schar, srep = string.format, string.byte, string.char, string.rep ------------------------------------------------------------------------ -- initialize ------------------------------------------------------------------------ if not hid.init() then print("hid library: init error") return end --====================================================================-- --** WARNING: Test uses Microchip's VID and a PID from MPLAB tools' ** --** PID range. DO NOT use outside of a laboratory/personal setting. ** --====================================================================-- local USB_DEVICE_VID = 0x1234 local USB_DEVICE_PID = 0x0001 local USB_REPORT_SIZE = 64 local dev = hid.open(USB_DEVICE_VID, USB_DEVICE_PID) if not dev then print("Open: unable to open test device") return end function addpadding(str) local length = string.len(str) for i=length, 7 do str = str .. " " end return str; end function call_speed (offset, value) local tx = "" tx = tx .. tostring(value); hidwrite(tx) end function hidwrite (buffer) buffer = addpadding(buffer) buffer = srep(buffer, USB_REPORT_SIZE / 8) local res = dev:write(buffer) if not res then print("Unable to write()") print("Error: "..dev:error()) return end end -- FSX events event.offset (0x07E2, "UW", "call_speed") -- aircraft speed after that I read that air speed value into joystick code (that i wrote in mikroc) and display that value to 7 segment LED. yes those are correct. getting from to run a program named "hid scanner.exe" I was thinking that com.write works like luahidapi. besides above conversation could you guide me? How do i display air speed value to 7 segment LED without serial communication?
  8. i think diagram will be like this
  9. oh i forgot to mention that i read HidDemo.lua, com.write or com.writefeature function was not used in that file.
  10. Hello Pete, Under of thanks for your response. Did you mean com port (COM1, COM2)? My expectation was that it will work like luahidapi library that im using right now that fulfills my requirements. but i want to use default com.write or com.writefeature function of fsuipc to write hid buffer. Ofcourse Arduino reads and writes to com port.. but i need to write to HID buffer. I read somewhere that HID is better than serial communication. Here's my ipc log. 36129 Running in "Microsoft Flight Simulator X", Version: 10.0.60905.0 (SimConnect: 2.0.60905.0) 200773 SimStart Event: Initialising SimConnect data requests 200789 FSUIPC Menu entry added 201288 C:\Users\szacpp\AppData\Roaming\Microsoft\FSX\Previous flight.FLT 201288 G:\Program Files\Microsoft Games\Microsoft Flight Simulator X\SimObjects\Airplanes\B737_800\Boeing737-800.AIR 201693 System time = 22/09/2017 19:59:38, Simulator time = 19:56:42 (02:56Z) 201803 Aircraft="Boeing 737-800 Paint1" 202598 Starting everything now ... 202723 LUA.0: beginning "G:\Program Files\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua" 202785 LUA.0: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:2 202801 LUA.0: Global: ipcPARAM = 0 202801 LUA.0: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:5 202801 LUA.0: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:6 202817 LUA.0: Local: USB_DEVICE_VID = 4660 202817 LUA.0: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:8 202817 LUA.0: Local: USB_DEVICE_PID = 1 202817 LUA.0: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:11 202817 LUA.0: Global: Device = 0 202817 LUA.0: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:18 202832 LUA.0: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:20 202832 LUA.0: Global: Report = 0 203456 LUA.0: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:21 203456 LUA.0: Global: wr = 65 203456 LUA.0: Global: wrf = 0 203472 LUA.0: Global: dev = 152504236 203472 LUA.0: Global: rd = 33 203472 LUA.0: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:29 203472 LUA.0: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:27 203487 LUA.0: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:32 203487 LUA.0: Waiting for an event in "G:\Program Files\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua" 203487 LUA.0: Offset Change event: calling "call_speed" in "G:\Program Files\Microsoft Games\Microsoft Flight Simulator X\Modules cReady.lua" 203487 LUA.0: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:28 203487 LUA.0: Local: offset = 2018 203487 LUA.0: Local: value = 0 203503 LUA.0: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:29 203503 LUA.0: Waiting for an event in "G:\Program Files\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua" 205235 Advanced Weather Interface Enabled 215437 *** EVENT: Cntrl= 65561 (0x00010019), Param= 0 (0x00000000) PAUSE_TOGGLE
  11. Hello Pete, Sorry for late reply, my internet was not working...now i'm online...Pete i'm using custom pic18f4550 joystick board. I want to get airspeed value into that chip or board by hid buffer using the mikroc code in previous post, mikroc is an IDE to write program for embedded system. i edited lua script according to you. now i got it that get and set are sessions variable. now problem is the edited code is not working according to my need.. and also im confused how does com.write function work?
  12. Thanks Thomas..I'll update then reply you :)
  13. hello Thomas I'm using FSUIPC4.937
  14. oh my mistake I did not set dev and wrf...I changed the code according to you Thomas, but it's not working...I'm confused that can I receive values that will be written by com.writefeature, into microcontroller? I'm using fsuipc ver 4.9 I'm glad for your response thankq very much
  15. thanks Volker for your response