Envisalink TPI interface using NC/Netcat

Information and support for EnvisaLink modules.

Moderators: EyezOnRich, GrandWizard

Post Reply
eagle
Posts: 7
Joined: Wed Mar 20, 2013 12:50 pm

Envisalink TPI interface using NC/Netcat

Post by eagle »

I'm trying to learn more about my Envisalink 3 TPI. As a start, I am using the NC command at the terminal on a Solaris 11 machine. So far, here's what I have:

> nc 1.2.3.4 4025
EVL3: 5053CD
Me: 005user54
EVL3: 5000052A
EVL3: 5051CB

So, then I'm logged in. I verify on the EVL3 web interface that TPI is connected. Here's where I keep running into trouble.

Me: 00191
EVL3: 50202029

It doesn't seem to matter what command I send, I receive the "system error" message 020, which says it's an API command syntax error. I've tried sending everything in hex (0x30303191), I've tried appending a 0D0A to the end of my command. Any ideas why I keep receiving the syntax error message?

I'm wondering if it has something to do with how the nc command is sending data. Maybe there's an option I should be using to ensure the data format is just as its typed?
rustyk
Posts: 15
Joined: Fri Feb 08, 2013 1:11 am

Re: Envisalink TPI interface using NC/Netcat

Post by rustyk »

Looks like you are missing part of the "checksum" at the end of your 001 command. Here's what it should look like:

You: 00191FB
EVL3: 50000126
EVL3: ...a whole lot of status lines

here's how I build the checksum in my php code:

Code: Select all

$command = "001";
$command = $command . build_checksum($command);
print $command;
// prints 00191FB

function build_checksum($command){
    $dec_total = 0;
    for ($i=0; $i < strlen($command); $i++){
        $dec_total += ord($command[$i]);
    }
    $checksum = strtoupper(dechex($dec_total % 256));
    return $checksum;
}
Hope this helps.
eagle
Posts: 7
Joined: Wed Mar 20, 2013 12:50 pm

Re: Envisalink TPI interface using NC/Netcat

Post by eagle »

Maybe I'm missing something. From what I can tell of the commands, the 001 (status report) command is not sent with any data bytes, so the checksum is calculated only on the 001. So the check sum is 30+30+31, which is 91. So 91 is the checksum and that is why I am sending 00191. is there a delimiter in there somewhere that I'm missing? Maybe 0010x91??

I found a simple perl script on here and used that to double check my excel sheet which calculates the checksums and assembles the commands for me. It also returned 00191 as the command.
rustyk
Posts: 15
Joined: Fri Feb 08, 2013 1:11 am

Re: Envisalink TPI interface using NC/Netcat

Post by rustyk »

Actually you were right, sorry about that, I was rushing this morning. You should be sending 00191.

The only thing I can think of is are you sending \r\n? I assume you are, otherwise the login wouldn't work.

Could you try using telnet maybe, to rule out anything weird with NC?
eagle
Posts: 7
Joined: Wed Mar 20, 2013 12:50 pm

Re: Envisalink TPI interface using NC/Netcat

Post by eagle »

Well, I tried telnet yesterday and it would not connect. Tried today and it was able to connect. I guess it was getting late and I had forgotten that the Envisalink will only support a single TPI connection. I was apparently still connected via NC while trying to telnet.

So, I was able to connect via telnet today and viola! It does respond correctly to the 00090 and 00191 commands just fine. I still want to get NC working because even though telnet can be scripted, NC seems to work faster and lighter. Maybe I'm wrong about that. I still want to try to figure out what NC is sending that causes it to make the syntax fail.
jaymemaurice
Posts: 1
Joined: Sun Sep 21, 2014 10:32 pm

Re: Envisalink TPI interface using NC/Netcat

Post by jaymemaurice »

Don't mean to wake the dead on this thread, but the provided php function won't work so well in calculating checksums that end up being "00"

perhaps:
return str_pad("$checksum",2,"0",STR_PAD_LEFT);
Post Reply