I think you are confusing a string with an array of bytes
Thank-you, now it works with bytes.
Hello.
I get a - Page not found - Error when i try to open the url
velleman.eu/images/tmp/VM201 … otocol.pdf
Has it been removed or relocated?
Should be restored within the next hour:
http://www.velleman.eu/images/tmp/VM201%20TCP%20protocol.pdf
[quote=“VEL417”]Should be restored within the next hour:
http://www.velleman.eu/images/tmp/VM201%20TCP%20protocol.pdf[/quote]
Thank you.
Hi everyone,
I am struglling with my VM201 and to be honnest I am a bit confused with the TCP protocol … I have read the pdf file provided in this topic but all the string of characters I have sent so far just ended in “Connection closed by foreign host”.
I am trying to get connected using username and password. On the VM201 website, the username and password field are 8 character long but on the pdf file nine are requested : <14>… (same for password).
If this (8 char instead of nine) is correct, the above command is not valid anymore and should read : <13>…
Am I right here ?
If so, could you please give me the approriate commands (LEN and CHECKSUM) for a login with username (11111111) and password (99999999) ? Using telnet (linux), what should be the string of characters to be sent (once the connection is open) ? (screenshots are more than welcome)
Thx a lot in advance for your time !
Cedric
[quote]I am struglling with my VM201 and to be honnest I am a bit confused with the TCP protocol … I have read the pdf file provided in this topic but all the string of characters I have sent so far just ended in “Connection closed by foreign host”.[/quote]What port are you connecting to?
[quote]If this (8 char instead of nine) is correct, the above command is not valid anymore and should read : <13>…[/quote]You are correct, this is an error in the protocol description
[quote]what should be the string of characters to be sent (once the connection is open) ? (screenshots are more than welcome)[/quote]Telnet can not be used here because you won’t be sending readable characters. If you read the protocol description, you will see packets described as “<6>…”. This doesn’t mean you should send it like that as text, rather each value inside “<>” represents one byte, so <6> for example means that you should send a byte with value 6.
Tip: If all this talk about bytes and packets confuses you, read this topic for an alternative:
viewtopic.php?f=37&t=8691&p=33437
Port is 9760.
Point on the protocol username /password error is taken.
I still have an issue with the way to convey the bytes… This talk about bytes and packets does really confuse me but my interest and curiosity are well above all that and this won’t stop me.
Tip is welcome too. I’ll have a look. I am still unsure whether the httpcommands will or not let me connect to the card through username/password. If the way out is username:password@vm201ip:port/…, it is not a convenient solution as I don’t want username and password to be sent clearly over the net… Php seems much better, expect that so far I am unable to send appropriate packets with username and password commands…
Thanks a lot for your time and patience.
[quote]php seems much better, expect that so far I am unable to send appropriate packets with username and password commands…[/quote]What does that PHP code look like so far?
And is your webserver hosted locally? Because your PHP code does not run in your browser but on the webserver, so the webserver needs to be inside your LAN.
I suppose another easy solution is a Perl script, with ActivePerl. Why? Because Perl is easy to learn, like PHP, and geared more towards what you want to do.
[quote=“VEL448”][quote]php seems much better, expect that so far I am unable to send appropriate packets with username and password commands…[/quote]What does that PHP code look like so far?
And is your webserver hosted locally? Because your PHP code does not run in your browser but on the webserver, so the webserver needs to be inside your LAN.[/quote]
Sorry for the late answer.
here is the php script (not mine, …) :
<?php
$fp = fsockopen("VM201_IP", 9760, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$hex = ("02065402A203");
$string="";
for ($i=0; $i < strlen($hex)-1; $i+=2)
{
$string .= chr(hexdec($hex[$i].$hex[$i+1]));
}
fwrite($fp, $string);
sleep(1);
echo fread($fp, 1024);
fclose($fp);
}
?>
This one is working just fine but when I try to append it with a new “string” to push to the card, the connection is force-closed by the host (the card I presume).
What could be the $hex string for a username/password message ? How to run the script : one for username followed by an other one for the password …(confused)
The purpose of all this is to protect the access of the card but still be able to run script within the LAN to modify the relays’ status (watering program). If rain is expected, timers off, if not, timers run as they are expected to.
I will have a look for sure but php first if feasible …
The protocol and authentication process is explained in this document:
velleman.eu/images/tmp/VM201.pdf
[quote=“VEL448”]The protocol and authentication process is explained in this document:
velleman.eu/images/tmp/VM201.pdf[/quote]
Cheers!
But would you please confirm that username and password should be padded to a length of 8 (and not 9 as written in the provided pdf) characters with zeroes?
I’ll give a try when work permits.
Thx again for your kindness. I’m really delighted with this card.
Cedric
Packet size is 14 bytes, and the username is 9 characters in length, padded with zeroes (like a C string).
I have started working on an implementation of the protocol in Python. In case someone here might be interested, the script can be found at github.com/tlrh314/misc/blob/master/vm201.py. At the moment of writing it is still work in progress. I have so far been able to receive information off the relay card, but I still have to implement the sending of packets part (e.g. user login, changing the state of the relays).
EDIT 14/10/2014 I have now implemented the functions to send packets as well. See github.com/tlrh314/misc/tree/master/vm201 for the full source code :-).