Home AMX User Forum NetLinx Studio

Kramer switcher programming

Hello. I'm trying to write a test program for Kramer vs808xl matrix switcher, and there is a problematic piece of code:
DEFINE_DEVICE
dvSwitcher = 5001:1:1 //1-st rs-232 port
dvDebug = 0:0:0 //debug device
...
DATA_EVENT
DATA_EVENT [dvSwitcher]
{
    COMMAND: {
	SEND_STRING dvDebug,"'SWITCHER COMMAND EVENT OCCURED'"
    }
    STRING: {
	SEND_STRING dvDebug,"'SWITCHER STRING EVENT OCCURED'"
    }
    ONLINE: {
	SEND_STRING dvDebug,"'SWITCHER DEVICE IS ONLINE'"
    }
    OFFLINE: {
	SEND_STRING dvDebug,"'SWITCHER DEVICE IS OFFLINE'"
    }
    ONERROR: {
	SEND_STRING dvDebug,"'SWITCHER ERROR OCCURED'"
    }
}
So, i think, when master makes SEND_STRING to or receives data from switcher, DATA_EVENT should be generated, and it should be visible in Diagnostics window (all notifications and diagnostic messages turned on). But Diagnostics window remains blank. What can be wrong?

Comments

  • DHawthorneDHawthorne Posts: 4,584
    The diagnostic window only shows system messages like you would see when you telnet into the master and use the "msg on" command. For device notifications, you need to be looking at the notifications window.
  • Thanks, but I look at both windows and don't see any messages about strings to device 0:0:0 (maybe i must look for them somewhere else?).

    P.S. Maybe it would be useful to add that my main purpose is to learn how to receive data from switcher by means of rs-232 port interface. But by now i can't even watch data transmittion with NetLinx (switcher works well when i send_string's to it).
  • dvDebug should be 0:1:0 !?!?!???
  • DHawthorneDHawthorne Posts: 4,584
    No, dvDebug should be 0:0:0; that part is OK. If you put a port number in, you are creating a TCP port. The debug port is 0.

    I don't really use the diagnostic window much, I use Telnet - but when you telnet in, you must type in "msg on" in order to see the send_strings to device 0. Perhaps there is a similar required mechanism for the diagnostic window, I don't know what it is though.
  • I'm now in doubt: do strings to rs-232 port generate DATA_EVENT? And what mechanism should i use to read data from rs-232 port?
  • Ilya wrote:
    I'm now in doubt: do strings to rs-232 port generate DATA_EVENT? And what mechanism should i use to read data from rs-232 port?

    Strings TO rs232 will not generate DATA_EVENTs, but only data received.


    This is some kind of typical rs232 handling. This example is based on the RS232 protcol of Panasonic VCRs.
    DEFINE_DEVICE
    dvPANEL      =   128:1:0 // Touchpanel
    dvVCR        =  5001:1:0 // seriell
    
    
    DEFINE_VARIABLE
    CHAR sVCR_BUFFER[500]    // Empfangspuffer von der seriellen
    INTEGER nVCR_STATUS = 0
    
    DEFINE_START
    CREATE_BUFFER dvVCR,sVCR_BUFFER
    
    DEFINE_EVENT
    DATA_EVENT[dvVCR]
    {
      ONLINE:
      {
        SEND_COMMAND DATA.DEVICE,'SET BAUD 9600,O,7,1'
      }
      STRING: 
      { 
        STACK_VAR CHAR sSCHROTT, sTMP[30]
        WHILE(LENGTH_STRING(sVCR_BUFFER) >= 5) // Panasonic: shortest responsehas 5 characters
        {
          IF(sVCR_BUFFER[1] = "$02") // start char
          {
            IF(FIND_STRING(sVCR_BUFFER,"$03",1)) // find end char
            {
              sTMP = REMOVE_STRING(sVCR_BUFFER,"$03",1)
              // sTMP checking....
              SELECT
              {
                ACTIVE(FIND_STRING(sTMP,"'OPL'",1)): { nVCR_STATUS = 1 }
                ACTIVE(FIND_STRING(sTMP,"'OSP'",1)): { nVCR_STATUS = 2 }
                ACTIVE(FIND_STRING(sTMP,"'OPA'",1)): { nVCR_STATUS = 3 }
                ACTIVE(FIND_STRING(sTMP,"'OFF'",1)): { nVCR_STATUS = 4 }
                ACTIVE(FIND_STRING(sTMP,"'ORW'",1)): { nVCR_STATUS = 5 }
                ACTIVE(1): { nVCR_STATUS = 255 } // any other response          }
            }
            ELSE // if no $03 found, check buffer to prevent overflow
            {
              IF(LENGTH_STRING(sVCR_BUFFER) >= (LENGTH_ARRAY(sVCR_BUFFER)-20))
              {
                sVCR_BUFFER = ''
              }
            }
          }
          ELSE // if no $02 start char at 1st position
          {
            sSCHROTT = GET_BUFFER_CHAR(sVCR_BUFFER)
          }
        }
      }
    }
    

    It depends on the protocol how to keep the WHILE alive and how to parse the data.
  • Joe HebertJoe Hebert Posts: 2,159
    Ilya wrote:
    So, i think, when master makes SEND_STRING to or receives data from switcher, DATA_EVENT should be generated
    Half right. When you send data TO the switcher via SEND_STRING dvSwitcher the DATA_EVENT for dvSwitcher will NOT fire. If you receive data FROM the switcher then the STRING handler for DATA_EVENT[dvSwitcher] WILL fire.
    DHawthorne wrote:
    when you telnet in, you must type in "msg on" in order to see the send_strings to device 0. Perhaps there is a similar required mechanism for the diagnostic window, I don't know what it is though.
    No required mechanism other than pushing the little hammer icon in. :)
    Ilya wrote:
    P.S. Maybe it would be useful to add that my main purpose is to learn how to receive data from switcher by means of rs-232 port interface. But by now i can't even watch data transmittion with NetLinx (switcher works well when i send_string's to it)..
    The switcher may not be sending anything back to you or there might be something wrong with the receive pin on the cable. For learning purposes here is one way to see the STRING handler fire for DATA_EVENT[dvSwitcher]:

    1) Remove the cable that connects Netlinx to the switcher and attach a loopback to pins 2 and 3 of the RS-232 port. You just need to short pins 2 & 3 together with a piece of wire.

    2) Enable Netlinx Internal Diagnostics Messages.

    3) Fire off the code that sends data to the switcher. When you do the data will be transmitted out of and looped back into your RS-232 port and ?SWITCHER STRING EVENT OCCURRED? will be printed to the Diagnostics window.

    4) Change

    SEND_STRING dvDebug,'SWITCHER STRING EVENT OCCURRED?

    To:
    SEND_STRING dvDebug,??SWITCHER STRING EVENT OCCURRED: ?,DATA.TEXT?

    5) Fire of the code that sends the data to the switcher and the data you sent (and then received) will be logged into the Diagnostic window.

    From there you can add variables to the code to hold that data you receive. And/or you can use CREATE_BUFFER to capture the data for you.

    If you want to see the ONLINE: handler for DATA_EVENT[dvSwitcher] get printed to the Diagnostics window try changing:

    SEND_STRING dvDebug,"'SWITCHER DEVICE IS ONLINE'"

    To:
    WAIT 100 SEND_STRING dvDebug,"'SWITCHER DEVICE IS ONLINE'"

    You may not be seeing the ONLINE handler being fired because it may have already happened before you were able to enable the internal messages after the master reboots. This gives you an extra 10 seconds to get it to see it captured.

    Hope some of this is useful. Good luck.
Sign In or Register to comment.