Home AMX User Forum NetLinx Studio

sending text to axcent3 from linux console

Hi,

I'm kind of new to netlinx, I got a couple of Axent3 and I wanted to make a simple alarm system. The system will send updates to my linux server via one of the rs232 ports and will receive some commands from it as well. Sending was not much of a problem, I got it to send the strings perfectly fine, now the receiving part is proving a lot more difficult than I imagined.

Here is the test code I'm using to test the received data:

PROGRAM_NAME='source_sec'

DEFINE_DEVICE
RELAY = 7
LAIN_S1 = 1
LAIN_S2 = 2
IO_IN = 14

DEFINE_CONSTANT
A = 120

DEFINE_VARIABLE
LABFF[1]
LA_CH


DEFINE_LATCHING

DEFINE_MUTUALLY_EXCLUSIVE

DEFINE_START
PULSE [RELAY,1]
PULSE [RELAY,2]
CREATE_BUFFER LAIN_S1,LABFF

DEFINE_PROGRAM
SEND_COMMAND LAIN_S1,'SET BAUD 9600,N,8,1,485 Disable'
IF (LENGTH_STRING (LABFF))
LA_CH = GET_BUFFER_CHAR (LABFF)

IF ( LA_CH = a )
{
ON [RELAY,2]
}

now from the linux side, I just send a echo for the "a" to the serial port:
echo a > /dev/ttyS1

the rs-232 led lights up, but the relay wont turn on.

Any help or pointers would be greatly appreciated
Douglas

Comments

  • ericmedleyericmedley Posts: 4,177
    IF ( LA_CH = 'a' )


    It's been a while since I've done any AXCESS but I think you need to put ticks around the 'a'. This may be wrong.

    you could also use FIND_STRING.

    IF(FIND_STRING(LA_CH,'a',1))
    {
    // DO SOMETHING
    LA_CH='' // CLEAR IT OUT
    }
  • Hi
    ericmedley wrote: »
    IF ( LA_CH = 'a' )


    It's been a while since I've done any AXCESS but I think you need to put ticks around the 'a'. This may be wrong.

    you could also use FIND_STRING.

    IF(FIND_STRING(LA_CH,'a',1))
    {
    // DO SOMETHING
    LA_CH='' // CLEAR IT OUT
    }

    Thanks for your replay, I tried both options but it still won't work, with the second I get the following message when I compile:

    source_sec.axs:Line 31:Type mismatch in function call 'FIND_STRING'
    source_sec.axs:Line 34:Syntax error 'EVAL'
  • dgordillo wrote: »
    Thanks for your replay, I tried both options but it still won't work, with the second I get the following message when I compile:

    source_sec.axs:Line 31:Type mismatch in function call 'FIND_STRING'
    source_sec.axs:Line 34:Syntax error 'EVAL'
    Quick question...I know you have AXcent3's and you have used the word NetLinx in your text, but is this an AXcess or NetLinx system?
  • dgordillo wrote: »
    Thanks for your replay, I tried both options but it still won't work, with the second I get the following message when I compile:

    source_sec.axs:Line 31:Type mismatch in function call 'FIND_STRING'
    source_sec.axs:Line 34:Syntax error 'EVAL'
    The use of find_string suggested by Eric is ideal.

    Regardless of my original question about which platform (for now), make sure that LA_CH is declared as follows:

    define_variable

    LA_CH[1]

    The following creates the exact error when compiled as AXcess...
    define_variable
    LA_CH
    
    define_program
    
    if( LA_CH = 'a' )
    
    
    IF(FIND_STRING(LA_CH,'a',1))
    {
     // DO SOMETHING
    LA_CH='' (*// CLEAR IT OUT *)
    }
    

    But this version is ok for AXcess...note the (* *) 'rem'ing' of the netlinx rems
    define_variable
    LA_CH[1]
    
    define_program
    
    if( LA_CH = 'a' )
    
    
    IF(FIND_STRING(LA_CH,'a',1))
    {
    (* // DO SOMETHING *)
    LA_CH='' (*// CLEAR IT OUT *)
    }
    

    Reason for my original question is that if it is Axcess you are programming, then the // used for comments will cause you the second part of the error.

    HTH
  • IT WORKS!!!
    The use of find_string suggested by Eric is ideal.

    Regardless of my original question about which platform (for now), make sure that LA_CH is declared as follows:

    define_variable

    LA_CH[1]

    The following creates the exact error when compiled as AXcess...
    define_variable
    LA_CH
    
    define_program
    
    if( LA_CH = 'a' )
    
    
    IF(FIND_STRING(LA_CH,'a',1))
    {
     // DO SOMETHING
    LA_CH='' (*// CLEAR IT OUT *)
    }
    

    But this version is ok for AXcess...note the (* *) 'rem'ing' of the netlinx rems
    define_variable
    LA_CH[1]
    
    define_program
    
    if( LA_CH = 'a' )
    
    
    IF(FIND_STRING(LA_CH,'a',1))
    {
    (* // DO SOMETHING *)
    LA_CH='' (*// CLEAR IT OUT *)
    }
    

    Reason for my original question is that if it is Axcess you are programming, then the // used for comments will cause you the second part of the error.

    HTH

    Ok, it's working now!!!! Thanks guys!!, I'm using Netlinx, and yep I did rem the //, the problem as far as I can tell was the LA_CH[1], when compiling it still gave a warning, but it did work when uploaded to the axcent3.

    this is the warning "source_sec.axs:Line 30:(w) Cannot assign unlike types "

    Stephen, Erick, Thanks again!
  • dgordillo wrote: »
    Ok, it's working now!!!! Thanks guys!!, I'm using Netlinx, and yep I did rem the //, the problem as far as I can tell was the LA_CH[1], when compiling it still gave a warning, but it did work when uploaded to the axcent3.

    this is the warning "source_sec.axs:Line 30:(w) Cannot assign unlike types "

    Stephen, Erick, Thanks again!
    No problem!

    If you want to post the version that gives this warning, I'd be happy to look at it again for you.

    Also, side note, you shouldn't put the set baud cmd in mainline - the box might get a bit cranky doing that.
  • test code

    PROGRAM_NAME='source_sec'

    DEFINE_DEVICE
    RELAY = 7
    LAIN_S1 = 1
    LAIN_S2 = 2
    IO_IN = 14

    DEFINE_CONSTANT
    a=9

    DEFINE_VARIABLE
    LABFF[1]
    LA_CH[1]

    DEFINE_LATCHING

    DEFINE_MUTUALLY_EXCLUSIVE

    DEFINE_START
    CREATE_BUFFER 1,LABFF
    PULSE [RELAY,1]
    PULSE [RELAY,2]

    DEFINE_PROGRAM

    IF (LENGTH_STRING (LABFF))
    LA_CH = GET_BUFFER_CHAR (LABFF)

    IF(FIND_STRING(LA_CH,'a',1))
    {
    on [relay,2]
    LA_CH=''
    }

    Hi Stephen, this is the code that works, but gives the warning message, It seems that the send command for the rs232 was not doing anything so I took it out, you sayd that it would not like it in the mainline, where should I put it?, I'm just guessing but is it on the define_start?

    Thanks again for all your help
  • patbpatb Posts: 140
    I haven't compiled this, but just from a quick glance off the top of my head it seems that the section

    IF (LENGTH_STRING (LABFF))
    LA_CH = GET_BUFFER_CHAR (LABFF)

    is probably what gives you the error. Since axcess does not have a type definition it assumes that any single variable is an integer and an array is a string. It is perfectly ok to have a string with one element as was mentioned by defining the LA_CH variable as LA_CH[1].

    What this code is telling the compiler is that I want to set an integer variable (LA_CH) equal to a string that I get when I use the GET_BUFFER_CHAR statement. Hence the warning for trying to assign unlike types.

    If you change LA_CH to LA_CH[1] instead it should compile and work fine.
  • patb wrote: »
    I haven't compiled this, but just from a quick glance off the top of my head it seems that the section

    IF (LENGTH_STRING (LABFF))
    LA_CH = GET_BUFFER_CHAR (LABFF)

    is probably what gives you the error. Since axcess does not have a type definition it assumes that any single variable is an integer and an array is a string. It is perfectly ok to have a string with one element as was mentioned by defining the LA_CH variable as LA_CH[1].

    What this code is telling the compiler is that I want to set an integer variable (LA_CH) equal to a string that I get when I use the GET_BUFFER_CHAR statement. Hence the warning for trying to assign unlike types.

    If you change LA_CH to LA_CH[1] instead it should compile and work fine.


    Hi,

    Yep, that did the trick!!! thanks patb.
  • Thank you for your help, just another question... what happens if I wanted to send a command like say... "hello" instead of just "a" and have the relay turn on...

    Douglas
  • dgordillo wrote: »
    Thank you for your help, just another question... what happens if I wanted to send a command like say... "hello" instead of just "a" and have the relay turn on...

    Douglas

    Sorry, never mind, I just edited the if to use the buffer like so:


    IF(FIND_STRING(LABFF,'hello',1))
    {
    on [relay,2]
    LA_CH=''
    }
  • dgordillo wrote: »
    It seems that the send command for the rs232 was not doing anything so I took it out, you sayd that it would not like it in the mainline, where should I put it?, I'm just guessing but is it on the define_start?

    Thanks again for all your help
    The send_command was/is doing something! - it is setting up the port. This is normally done just once, and in AXcess, this time is in define_start.

    The port won't forget its setting on power cycle or anything, but it is a very good practice to have this as a line in your code so that if you have to swap out a processor or something, your code, once re-installed will setup the port and all will be well again.
    I'm using Netlinx, and yep I did rem the //, the problem as far as I can tell was the LA_CH[1], when compiling it still gave a warning, but it did work when uploaded to the axcent3.

    I'm still confused as to wether this system has a NetLinx master attached to your AXcent3 or it's just the Axcent3! The declarations indicate Axcess...(No D:P:S, no events etc) but your comments NetLinx! Maybe this refers to NetLinx Studio.

    :-)


    What I have described above regarding the send_command is suitable for an AXcess master, not NetLinx.

    HTH
  • The send_command was/is doing something! - it is setting up the port. This is normally done just once, and in AXcess, this time is in define_start.

    The port won't forget its setting on power cycle or anything, but it is a very good practice to have this as a line in your code so that if you have to swap out a processor or something, your code, once re-installed will setup the port and all will be well again.



    I'm still confused as to wether this system has a NetLinx master attached to your AXcent3 or it's just the Axcent3! The declarations indicate Axcess...(No D:P:S, no events etc) but your comments NetLinx! Maybe this refers to NetLinx Studio.

    :-)


    What I have described above regarding the send_command is suitable for an AXcess master, not NetLinx.

    HTH

    Hi,

    Yes, I was referring to the Netlinx Studio, you see I got a couple of Axcent3 controllers and I'm just starting to learn what they are capable of, so far I'm really impress with what they can do. So I didn't even know of the other product lines of AMX, sorry for the confusion.

    The project I had in mind was to use the Axcent as an alarm system and have it interact with my linux server. The idea is to have it work the alarm system by it self without any interaction with the server in case it should be offline for some reason, but if it where to be on-line the server will do a couple of other things like: Call 911, call me at my cel, take video feed from the camera system and store it off-site.

    For this I will have it interact with a perl program running on the server, the server is running asterisk which of course is going to handle the actual calling, the server is also using festival for text to speech to the pa system, and the last part will be to use sphinx to have speech recognition for controlling lights and other stuff.

    Thank you so much for the time and tips.
    Douglas
  • dgordillo wrote: »
    Hi,

    Yes, I was referring to the Netlinx Studio, you see I got a couple of Axcent3 controllers and I'm just starting to learn what they are capable of, so far I'm really impress with what they can do. So I didn't even know of the other product lines of AMX, sorry for the confusion.

    The project I had in mind was to use the Axcent as an alarm system and have it interact with my linux server. The idea is to have it work the alarm system by it self without any interaction with the server in case it should be offline for some reason, but if it where to be on-line the server will do a couple of other things like: Call 911, call me at my cel, take video feed from the camera system and store it off-site.

    For this I will have it interact with a perl program running on the server, the server is running asterisk which of course is going to handle the actual calling, the server is also using festival for text to speech to the pa system, and the last part will be to use sphinx to have speech recognition for controlling lights and other stuff.

    Thank you so much for the time and tips.
    Douglas
    Sounds very interesting!

    For the dialing, you could plug a simple modem in which would allow you to dial in to the AXcent, and get it to dial out using AT cmd set.

    Good luck!
Sign In or Register to comment.