Delta Tau GEO BRICK LV User Manual

Page of 440
 
Turbo PMAC User Manual 
418 
Writing a Host Communications Program 
For example, the following multi-line string could be sent in a single packet: OPEN PLC 1 
CLEAR<00>P1=P1+1 <00> CLOSE<00>
, where <00> indicates a null byte.  The maximum data 
length is 1024 bytes; anything bigger must be separated into multiple calls of 
VR_PMAC_WRITEBUFFER.   
Upon receiving this packet, the Turbo PMAC Ethernet interface sends back 4 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 Turbo PMAC error 
type if there was a download error.  Consult the Turbo PMAC Software Reference summary or error list 
under variable I6.  Bytes 0 and Byte 1 together form a WORD that indicates the line number that 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 permits writing raw data to the Turbo PMAC host port for firmware download.  The Ethernet 
firmware takes the stream of data, then writes to the Turbo PMAC CPU host port at addresses {base + 5}, 
{base + 6}, and {base + 7}.  The packet includes in the wValue parameter to command to start the 
download at host port address {base + 5}.  This packet permits writing multiple lines to the Turbo PMAC 
with just 1 packet.   
The packet is set up as follows.  The received data is the response to the sent control character.  It is 
usually used for downloading a file.  Data should be of the form each line separated by null byte. After 
sending the packet the programmer must wait to receive 1 byte via the recv function before continuing. 
The data received is irrelevant; its purpose is to insure 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 Turbo PMAC, then to return any available 
strings that may be residing in the Turbo 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 will ever be returned is 1400 Bytes.  It is the caller's responsibility to 
logically 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;