User's Manual
UMAC Turbo CPU/Communications Board Hardware Manual
Ethernet Protocol 37
VR_PMAC_WRITEBUFFER
This packet writes multiple lines to the PMAC with just one packet. Set up the packet as follows. The
received data is the response to the sent control character. Usually, it is used for downloading a file. Data
should have each line separated by null byte.
For Example, OPEN PLC 1 CLEAR<00>P1=P1+1<00>CLOSE<00> where <00> indicates a null byte.
The maximum data length is 1024; anything bigger must be separated into multiple calls of
VR_PMAC_WRITEBUFFER. Upon receiving this packet, the PMAC sends back four bytes of data.
Byte 3 indicates if there was an error downloading. If the value of this byte is 0x80, there was an error
during the download. If it is 0, there was no error during download. Byte 2 indicates the PMAC Error
type if there was a download error. Consult the PMAC Software Reference manual under I6. Bytes 0
and Byte 1 together form a word that indicates the line number which caused the error to occur. Byte 1 is
the MSB and Byte 0 is the LSB of that word.
Example:
char errcode[4];
EthCmd.RequestType = VR_DOWNLOAD;
EthCmd.Request = VR_PMAC_WRITEBUFFER;
EthCmd.wValue = 0;
EthCmd.wIndex = 0;
EthCmd.wLength = htons(len) ;
memcpy(EthCmd.bData,data, len);
send(sock,(char *)&EthCmd,ETHERNETCMDSIZE + len,0);
recv(sock,(char *)errcode,4 ,0);
VR_FWDOWNLOAD
This packet writes raw data to the UMAC Turbo CPU/Communications Board host port for firmware
download. The firmware takes the stream of data, and then writes to the UMAC Turbo
CPU/Communications Board host port at address 5, 6 and 7. The packet includes the wValue parameter
that commands the start the download at host port address 5. This packet writes multiple lines to the
UMAC Turbo CPU/Communications Board with just one packet. The packet is set up as follows. The
received data is the response to the sent control character. Usually, it is used for downloading a file. Data
should have each line separated by null byte. After sending the packet, the programmer must wait to
receive one byte via the recv function before continuing. The data received is irrelevant; its purpose is to
ensure that the sender’s command was received.
EthCmd.RequestType = VR_DOWNLOAD;
EthCmd.Request= VR_FWDOWNLOAD;
EthCmd.wValue = htons((WORD)bRestart); //bRestart = 1 on start
EthCmd.wIndex = 0;
EthCmd.wLength = htons((WORD)len) ;
memcpy(EthCmd.bData,data, len);
send(sock,(char *)&EthCmd,ETHERNETCMDSIZE + len,0);
recv(sock,(char *)&errcode,1 ,0);
VR_PMAC_GETRESPONSE
This packet causes the Ethernet connection to send a string to UMAC Turbo CPU/Communications
Board, then to return any available strings that may be residing in the PMAC. All characters up to an
<ACK> or <LF> are returned. If a <BEL> or <STX> character is detected, only the data up to the next
<CR> is returned. The maximum amount of data that is returned is 1400 Bytes. It is the caller’s
responsibility to determine if there is more data to follow and if VR_PMAC_GETBUFFER needs to be
called again to retrieve all of the data available.
EthCmd.RequestType = VR_DOWNLOAD;
EthCmd.Request = VR_PMAC_GETRESPONSE;
EthCmd.wValue = 0;