Posts: 53
Threads: 20
Joined: Apr 2017
Reputation:
1
20.04.2017, 10:45
(This post was last modified: 20.04.2017, 11:43 by leonidas .)
Hello,
I have a code which logs every char received be serial port:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
if not port then
require (
'serial' )
port =
serial.open (
'/dev/RS232' , {
baudrate =
9600 ,
parity =
'none' ,
duplex =
'full' })
port :
flush ()
end
if port then
char =
port :
read (
1 ,
1 )
if char then
alert (
char )
end
end
What I need is to find specific string in received data. For example "OUT1ON" or "OUT1OFF" and based on it control KNX object. Maybe someone can help me with that?
Posts: 8075
Threads: 43
Joined: Jun 2015
Reputation:
471
Is this input separated somehow - by a new line character or similar?
Posts: 53
Threads: 20
Joined: Apr 2017
Reputation:
1
20.04.2017, 11:08
(This post was last modified: 20.04.2017, 12:01 by leonidas .)
In device manual it says last byte is <cr>. "Module must end with carriage return (ASCII #13)"
Posts: 8075
Threads: 43
Joined: Jun 2015
Reputation:
471
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
if not port then
require (
'serial' )
port =
serial.open (
'/dev/RS232' , {
baudrate =
9600 })
port :
flush ()
line =
''
end
char =
port :
read (
1 ,
1 )
if char then
if char ==
'\r' then
line =
line :
trim ()
alert (
line )
line =
''
else
line =
line ..
char
end
end
Posts: 53
Threads: 20
Joined: Apr 2017
Reputation:
1
Posts: 85
Threads: 16
Joined: Jun 2016
Reputation:
2
(20.04.2017, 12:10) admin Wrote: Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
if not port then
require (
'serial' )
port =
serial.open (
'/dev/RS232' , {
baudrate =
9600 })
port :
flush ()
line =
''
end
char =
port :
read (
1 ,
1 )
if char then
if char ==
'\r' then
line =
line :
trim ()
alert (
line )
line =
''
else
line =
line ..
char
end
end Hi Admin,
I have a question about RS232 i have try this profil with RS485 but i want (because i have many devices on RS485 and only this on Rs232) to put this device on RS232 with script but i don't now how make that :
{
"manufacturer" :
"TEST" ,
"description" :
"TEST" ,
"mapping" : [
{
"name" :
"1" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 0,
"value_bitmask" : 0x00FF,
"writable" : 0},
{
"name" :
"2" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 0,
"value_bitmask" : 0xFF00,
"writable" : 0},
{
"name" :
"3" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 1,
"value_bitmask" : 0x00FF,
"writable" : 0},
{
"name" :
"4" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 1,
"value_bitmask" : 0xFF00,
"writable" : 0},
{
"name" :
"5" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 2,
"value_bitmask" : 0x00FF,
"writable" : 0},
{
"name" :
"6" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 2,
"value_bitmask" : 0xFF00,
"writable" : 0},
{
"name" :
"7" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 3,
"value_bitmask" : 0x00FF,
"writable" : 0},
{
"name" :
"8" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 3,
"value_bitmask" : 0xFF00,
"writable" : 0},
{
"name" :
"9" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 4,
"value_bitmask" : 0x00FF,
"writable" : 0},
{
"name" :
"10" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 4,
"value_bitmask" : 0xFF00,
"writable" : 0},
{
"name" :
"11" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 5,
"value_bitmask" : 0x00FF,
"writable" : 0},
{
"name" :
"12" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 5,
"value_bitmask" : 0xFF00,
"writable" : 0},
{
"name" :
"13" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 6,
"value_bitmask" : 0x00FF,
"writable" : 0},
{
"name" :
"14" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 6,
"value_bitmask" : 0xFF00,
"writable" : 0},
{
"name" :
"15" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 7,
"value_bitmask" : 0x00FF,
"writable" : 0},
{
"name" :
"16" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 7,
"value_bitmask" : 0xFF00,
"writable" : 0},
{
"name" :
"17" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 8,
"value_bitmask" : 0x00FF,
"writable" : 0},
{
"name" :
"18" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 8,
"value_bitmask" : 0xFF00,
"writable" : 0},
{
"name" :
"19" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 9,
"value_bitmask" : 0x00FF,
"writable" : 0},
{
"name" :
"20" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 9,
"value_bitmask" : 0xFF00,
"writable" : 0},
{
"name" :
"21" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 10,
"value_bitmask" : 0x00FF,
"writable" : 0},
{
"name" :
"22" "bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 10,
"value_bitmask" : 0xFF00,
"writable" : 0},
{
"name" :
"23" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 11,
"value_bitmask" : 0x00FF,
"writable" : 0},
{
"name" :
"24" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 11,
"value_bitmask" : 0xFF00,
"writable" : 0},
{
"name" :
"25" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 12,
"value_bitmask" : 0x00FF,
"writable" : 0},
{
"name" :
"26" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 12,
"value_bitmask" : 0xFF00,
"writable" : 0},
{
"name" :
"27" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 13,
"value_bitmask" : 0x00FF,
"writable" : 0},
{
"name" :
"28" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 660,
"value_bitmask" : 0x00FF,
"writable" : 0},
{
"name" :
"29" ,
"bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 660,
"value_bitmask" : 0xFF00,
"writable" : 0},
{
"name" :
"30" "bus_datatype" :
"07" ,
"type" :
"register" ,
"datatype" :
"uint16" ,
"address" : 668,
"value_bitmask" : 0x00FF,
"writable" : 0}
]
}
Thanks a lot.
Posts: 8075
Threads: 43
Joined: Jun 2015
Reputation:
471
What kind of device is it? Is it ModBus RTU or ASCII over RS-232?
Posts: 85
Threads: 16
Joined: Jun 2016
Reputation:
2
(16.03.2018, 17:17) admin Wrote: What kind of device is it? Is it ModBus RTU or ASCII over RS-232?
Hi admin,
I am attaching the product documentation. For me it is in RS232 ...
Thank you for your understanding
Attached Files
Posts: 8075
Threads: 43
Joined: Jun 2015
Reputation:
471
Well, this should work with ModBus mapper and correct profile. You do not need any scripts here. Start with configuring correct RTU serial port and settings and then use RTU read test.
Posts: 85
Threads: 16
Joined: Jun 2016
Reputation:
2
(19.03.2018, 07:36) admin Wrote: Well, this should work with ModBus mapper and correct profile. You do not need any scripts here. Start with configuring correct RTU serial port and settings and then use RTU read test.
Hi,
In fact that's what I thought too but after setting all parameters no discussion so the manufacturer told me that his machine was working in RS232 so that's why I wanted to do the test with a script.
Thank you.
Posts: 8075
Threads: 43
Joined: Jun 2015
Reputation:
471
It does not matter for ModBus mapper whether you are using RS-232 or RS-485. The only thing that matters is to set correct duplex if using selectable RS-232/RS-485 port on LM5.
Posts: 85
Threads: 16
Joined: Jun 2016
Reputation:
2
(20.03.2018, 09:12) admin Wrote: It does not matter for ModBus mapper whether you are using RS-232 or RS-485. The only thing that matters is to set correct duplex if using selectable RS-232/RS-485 port on LM5.
Hello,
I am currently on a SpaceLynk I have several devices RS485 (heat pump, central air treatment ...) that work very well without the equipment we are talking about.
That's why I would have liked to put it following the request of the supplier on the RS232 port so it is necessary to pass on scripts?
Thank you.