<NULL> in serial command

Announcements, questions
Post Reply
Gerrit_001
Posts: 3
Joined: 14 Jul 2021, 15:51

<NULL> in serial command

Post by Gerrit_001 » 14 Jul 2021, 16:33

Hello! I hope somebody can help me with this one.
I want to activate a present on a device (PTZ camera) with a serial command (RS232).
I can send ASCII string but the device needs a specific serial command.
The problem is that when the value <NULL> is send the <NULL> isn’t send and also other consecutive bytes after the <NULL>.
Does anybody know a work around?

The code:

Code: Select all

lmc_device_set_name('KEYBOARD','29020817')
lmc_add_com('C4', 'COM4')
lmc_print_devices()

Preset01 = string.char(160,1,0,7,0,1,175,8)

lmc_set_handler('C4',function(comVal)
  if (comVal == Preset01) then
  print('Preset 1 activated on another device')

end

end
)

lmc_set_handler('KEYBOARD', function(button,direction)
  if (direction == 0) then return end

  if (button == 67) then
  lmc_send_to_com('C4', Preset01)

  else print('Key to assign: ' .. button)

  end

end
)

De only bytes that are send are 160 and 001.

admin
Site Admin
Posts: 735
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Re: <NULL> in serial command

Post by admin » 15 Jul 2021, 07:45

The serial library probably internally uses null terminated strings so taking your first 0 as end of the string.
I'll try to check, maybe I could add function to send single byte...
Petr Medek
LUAmacros author

Gerrit_001
Posts: 3
Joined: 14 Jul 2021, 15:51

Re: <NULL> in serial command

Post by Gerrit_001 » 15 Jul 2021, 11:50

admin wrote:
15 Jul 2021, 07:45
The serial library probably internally uses null terminated strings so taking your first 0 as end of the string.
I'll try to check, maybe I could add function to send single byte...
If that's possible it would be greate!

Gerrit_001
Posts: 3
Joined: 14 Jul 2021, 15:51

Re: <NULL> in serial command

Post by Gerrit_001 » 22 Aug 2021, 11:35

Did you found the time to look into this?

admin
Site Admin
Posts: 735
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Re: <NULL> in serial command

Post by admin » 30 Aug 2021, 08:05

Not yet...
Petr Medek
LUAmacros author

Post Reply