Author Topic: Pause between hex send command HELLLLLLLLPPPPPPPPPPPPPPP Program Tip required  (Read 53 times)

Offline Newzwaver

  • Full Member
  • ***
  • Posts: 177
  • Karma: +4/-3
Hi All

I have a scene that works and sends a command to change volume below
local socket = require("socket")
host = "192.168.2.88"
c = assert(socket.connect(host, 10006))
c:settimeout(5)
-- 0x02 + 0x00 + 0x01 + 0x15 + 0x6C + Checksum
local sres, serr = c:send(string.char(0x02,0x00,0x01,0x04,0x57,0x5E))-- testing
print("Send:", sres, serr)

local data, rerr = c:receive(300)
luup.log (data)
print ("Receive:", data, rerr)
local sres, serr = c:send(string.char(0x02,0x01,0x01,0x15,0xF6,0x0F))-- Channel 2 up
print("Send:", sres, serr)
local data, rerr = c:receive(300)
luup.log (data)
print ("Receive:", data, rerr)

local sres, serr = c:send(string.char(0x02,0x00,0x01,0x04,0x57,0x5E))-- testing
print("Send:", sres, serr)

local data, rerr = c:receive(300)
luup.log (data)
print ("Receive:", data, rerr)
local sres, serr = c:send(string.char(0x02,0x01,0x01,0x15,0xF6,0x0F))-- Channel 3 up
print("Send:", sres, serr)
local data, rerr = c:receive(300)
luup.log (data)
print ("Receive:", data, rerr)

c:close()

I have converted that into the following and it doesnt work HELPPPPPP 

      local volume33 = luup.attr_get(lul_settings.DesiredVolume)
      volume11 = volume33 + 196
      Vvalue = "0x" .. string.format( "%02x", volume11 )
      local keyPad = luup.attr_get('altid', lul_device)
      local keyCode = luup.attr_get('altid', lul_device)
      KeyString = "0x" .. string.format( "%02x", keyCode )

      local chksums2 = 0x02 + 0x01 + KeyString + 0x15 + Vvalue
      local chksums = 0x02 + 0x00 + KeyString + 0x04 + 0x57
      
      -- Send command 0x02,0x00,0x01,0x04,0x57,0x5E
      cmdString = { 0x02, 0x00, 0x01, 0x04, 0x57, 0x5E }
      sendCommand(makeCommand(cmdString))
      cmdString = { 0x02, 0x01, KeyString, 0x15, Vvalue, chksums2 }
      sendCommand(makeCommand(cmdString))
         -- Send command
      cmdString = { 0x02, 0x00, KeyString, 0x04, 0x57, chksums }
      sendCommand(makeCommand(cmdString))
      cmdString = { 0x02, 0x01, KeyString, 0x15, Vvalue, chksums2 }
      sendCommand(makeCommand(cmdString))   

The only thing that I can figure out is that the scene code has a delay,any help would be greatly appreciated.

Thanks