baud rate quistion
udi
Posts: 107
I want to change the baud rate of port 2 (the rs-232) of the AMX device to 2400 how can I do that?
0
Comments
check the documentation for your device. You just need to send a command to the port to make the change.
But, here's how to find out what the setting currently is:
send_command 5001:2:0,'GET BAUD'
See the result in diagnostic notifications.
then:
send_command 5001:2:0,'SET BAUD 2400'
will change it.
or the full configuration:
SEND_COMMAND 5001:2:0,'SET BAUD 2400,N,8,1 485 DISABLE'
It is important to do this command in the DATA_EVNT..ONLINE of the port, like
DEFINE_DEVICE
dvSerial2 = 5001:2:0
DEFINE_EVENT
DATA_EVENT[dvSerial2]
{
ONLINE:
{
SEND_COMMAND dvSerial2,'SET BAUD 2400,N,8,1 485 DISABLE' // 2400 bau, no parity, 8 databits, 1 StoppBit
SEND_COMMAND dvSerial2,'XOFF' // software handshake off
SEND_COMMAND dvSerial2,'HSOFF' // hardware handshake off
SEND_COMMAND dvSerial2,'CHARD-0' // no character delay
}
}
Send the 'SET BAUD' command to the device in question. You need to know what device that is. If it's a Netlinx box, the second serial port is most likely 5001:1:0. If it's an Axcent3 box, it's probably 2. If it's an Axcent box slaved to a Netlinx, or any other configuration other than the second serial port on a stand alone integrated master, you need to figure out how to address the port.
In any event, get the documentation for whatever device you have and read the part about programming the serial ports and all the details of 'SET BAUD' will be revealed.
thank for your help. I did the command but I am not getting exactly the hex code I need to get.
I get the code:
Line 4 (10:25:11):: String From [5001:3:1]-[$08$0D$05$00$00$00$00$124.$FE]
But the HEX code I need to get is :
[$08$0D$05$00$00$00$00$12$34$2E$FE]
What is the problem why I don’t get the end of the code correctly?
In addition I have another problem. I need to calculate the CRC and I found a code in the forum but I don’t know if I do the correct thing. I need to add the calculate I get into the end of the string and then sending it to the device.
I tried for exanple the command:
SEND_STRING dvSerial3,"'$0A$0D$0F$04$00$03$00$01$01$FF$FF',(crc16('$0A$0D$0F$04$00$03$00$01$01$FF$FF'))"
SEND_STRING dvSerial3,"'$0A$0D$0F$04$00$03$00$01$01$FF$FF',(fuCrcCalc('$0A$0D$0F$04$00$03$00$01$01$FF$FF'))"
I tried the two functions that appear in the forum:
http://www.amxforums.com/showthread.php?4849-Help-with-quot-Pima-quot-Alarm-System-CRC&highlight=PIMA
but each gives me different result and it dosent sent the string correct
//the crc16 function
Line 14 (10:25:27):: String To [5001:3:1]-[$0A$0D$0F$04$00$03$00$01$01$FF$FFo$E4]
//the fuCrcCalc function
Line 15 (10:25:27):: String To [5001:3:1]-[$0A$0D$0F$04$00$03$00$01$01$FF$FF6F]
They don’t sent the command in hex in the end. How do I need to do that?
I want to send the command in HEX is the command correct?
I added my code file the functions is in the code.
Thanks for any help that leads me in the right direction. Examples are very much appreciated
how can I do that?
[$08$0D$05$00$00$00$00$12$34$2E$FE]
Line 4 (10:25:11):: String From [5001:3:1]-[$08$0D$05$00$00$00$00$124.$FE]
All bytes from $08 up to $12 are non-displayable, so they are shown as hex, but the "$34,$2E" are displayable ASCII, and so the notification will show them as "4.". The last byte "$FE" again is nondisplayable, and so shown as hex again.
Regarding the crc checksum functions
SEND_STRING dvSerial3,"'$0A$0D$0F$04$00$03$00$01$01$FF$FF',(fu CrcCalc('$0A$0D$0F$04$00$03$00$01$01$FF$FF'))"
The string you put in to calculate the checksum is an ASCII string, including also the "$" symbols for the checksum. But the chekcsum is required to be calculated by the hex values, so the code might be
SEND_STRING dvSerial3,"$0A,$0D,$0F,$04,$00,$03,$00,$01,$01,$FF,$FF,fuCrcCalc("$0A,$0D,$0F,$04,$00,$03,$00,$01,$01,$FF,$FF")"
If you want to all hex displayed then from the menu bar goto:
Settings --> Preferences --> Diagnostics and then select Display as… Hex Values in the Notification View.
Again, this may be just the display issue. This may be shown as E4 in notification, but if it has no leading $ symbol, it may be 2 byte values that can be displayed, and so in hex display, it would be "$45,$34".
P.S.: Thank you Hedberg, I didn't know that settings option
I am trying to sending variable that have the string "$0A,$0D,$0F,$04,$00,$03,$00,$01,$01,$FF ,$FF" instead of sending the string itself
For example
SEND_STRING dvSerial3,"MSG,fuCrcCalc("MSG")"
How can I do that?
I tried the code:
LOCAL_VAR MSG [1000]
MSG = "$0A,$0D,$0F,$04,$00,$03,$00,$01,$01,$FF,$FF"
But the MSG get the string "$0A$0D$0F$04" I changed the length to 3000 but he also get the same string.
In addition, I want to put the data.text I get from the alarm into an array that could help me to get to the data in the array.
Thanks should go to Joe Hebert, not to me.
There is not a binary integer type in Netlinx. You'll have to create a routine to convert it to a string or populate an integer array.
Hex is binary is decimal is octal etc, same value just different representations. The NCL math library has a function for encoding an int to binary coded decimal if you're device is looking for that, or are you needing to convert it to an ASCII representation of the binary value?
for example:
byte 28 of the frame I get from the alarm indicates the open zones status for zones 1 to 8. so if byte 28 of the data: data.text[28] = 08H that means in binary 00001000 so zone 4 is open.
In addition, someone can help me with the string issue I wrote.
As for the string issue there's a bug in NS diagnostics that will terminate outgoing string display on a null character ($00). The whole string will be going to the device, the output window just won't show it.
if I am getting $14 from the device, so the binary is "00010100" and I want to check if zone 3 is open so I need to do:
if(getZoneStatus($14,3))
{
//////DO SOMETHING IF TRUE
}
ELSE
{
//////DO SOMETHING IF TRUE
}
status of the 3rd bit of the 28th byte of the device response:
if(getZoneStatus(data.text[28],3))
{
//DO SOMETHING IF TRUE
}
ELSE
{
//DO SOMETHING IF FALSE
}
now what about my other question. can anyone help me? Examples are very much appreciated .
See my previous post ^^
LOCAL_VAR MSG [1000]
MSG = "$0A,$0D,$0F,$04,$00,$03,$00,$01,$01,$FF,$FF"
SEND_STRING dvSerial3,"MSG,fuCrcCalc("MSG")"
how can I know what size the array should be?
'should be'??? well, length_string(MSG) will return an integer value of the current length of the array. In the example you gave, it will be 11.