ok, it is now clear how it tries to communicate with the board.
i first have to tell you that the protocol seems really awkward, mixing ascii and binary messages...
the socket is indeed an UDP socket. UDP is only available starting with CVI 8.5. if you use an earlier version of CVI you will have to use windows network API through the winsock library.
the computer seems to need being located at address 192.168.2.101 when using this python snippet... for whatever reason. there may be a filtering on the board preventing from communicating with the board if the message does not come from this address (my guess is that the author did not know how to retrieve the local address to setup the socket).
an address and a port (which we will now refer to as IP and PORT) are specified somewhere, maybe in a configuration file (they are stored in variables
comm['ethernet'][0] and comm['ethernet'][1]).
the computer sends messages to the board at address IP on port PORT+1, and listen to replies on port PORT.
to 'establish' a connection, the computer sends the message "hello" to the board, until the board replies. the content of the reply seems not relevant since it is simply discarded.
messages are comprised of a command number, a separator and a command.
- the command number is a short int (2 bytes) written in binary, least significant byte first. the command number seems to be increased by one for each command transmitted to the board.
- the separator is always ':'
- the command is the ascii command. i'm not sure about the terminating null character, but i think you should NOT send it (python does not use a terminating null character for strings)
the given snippet waits 100ms after each command. i don't have the code of the quit() function, it may wait for a reply...
from the snippet you give, valid commands are:
- shutter off:
'pj2=o' followed by 'pj2=0'
- shutter on: 'pj2=o' followed by 'pj2=1'
example: if the 12th command sent to the board is a shutter on, you will send to the board the string "\x0c\x00:pj2=o" followed by "\x0d\x00:pj2=1".
(i don't know how to disable that smiley thingy ! the smileys are ':' followed by 'p')
i hope this helps...
Message Edited by dummy_decoy on
01-22-2008 03:31 PM