www.vtiinstruments.com
EX1629 Onboard Memory
323
These are the actual opcodes for four of the five functions we outlined above. They are 1-Wire bus
commands that are sent to the 1-Wire (TEDS) devices. The GET_URN function is not listed
because it is not a single opcode that modifies data on the device or returns data except for the
serial number/URN.
//Device-specific values
#define DS2430_SCRATCHPAD_LEN 32
#define DS2431_SCRATCHPAD_LEN 8
#define DS2430_MEMORY_LEN 32
#define DS2431_MEMORY_LEN 144
#define EX1629_MAX_TEDS_READ 32
These are the values that will be seen in the code, and are fairly self explanatory. The
EX1629_MAX_TEDS_READ is an artifact of implementation – the minimum MLAN buffer is
48 bytes, which is what is supported by the EX1629. To avoid overruns, however, our example
code will only read 32 bytes at a time, plus some MLAN overhead which will be explained later.
uint8_t SendPkt[256];
uint8_t RecPkt[256];
These are global buffers which will be used to store the sent and received packets.
Before beginning with the listed functions, a short example will be examined and described in
detail.
int example_function(int channel)
{
int sendLen, recLen = 0;
sendLen = 1; // reserve first byte for length
SendPkt[+] = CMD_RESET;
SendPkt[+] = CMD_GETBUF;
SendPkt[0] = sendLen - 1;
MLanHostPacketSend(SendPkt, channel);
recLen = MLanHostPacketReceive(RecPkt, channel, MLAN_PACKET_SIZE);
return recLen;
}
This function performs an MLAN bus master reset, that is, it resets the MLAN repeater inside the
EX1629. As can be seen, the first byte of the packet is reserved for the length of the packet. This
not only defines a maximum size for an MLAN packet, but also tells the controller how much
space to allocate for it. This is done for every packet sent. The controller also uses the first byte as
the length of every packet received. Command and data bytes are appended to the byte array, with
a post-increment of the index (sendLen).
The first command sent is CMD_RESET, or 0x84.
This is the command that performs the bus
master reset. The next command is CMD_GETBUF, or 0x84. This returns the response buffer
from the repeater.
Here is the program’s output, given just this function:
sent packet without errors
Packet length: 3
02 84 85
got a packet without errors on receive
Packet length: 3
02 84 00
The first line indicates that the driver call used to send the data was successful. The second
indicates how long the packet sent was: 3 bytes, which is what was expected. The next line is the
printout of the packet. The first byte in the packet, as previously stated, is the length of the packet.
Содержание EX1629
Страница 310: ...VTI Instruments Corp 310 EX1629 Command Set...
Страница 342: ...VTI Instruments Corp 342 EX1629 Onboard Memory...