Synchronous Request Message

A Synchronous Request (SREQ) Message is the first message of a two-way handshake. A SREQ message always returns a Synchronous Response (SRSP) message. (Note: an Asnychronous Request Message (AREQ) does not have an SRSP). In an example like Get Version you can see the basic call stack of a Synchronous Request:
 * 1) The example calls getVersion
 * 2) In module.c getVersion then calls sendMessage in the Module Physical Interface file (e.g. zm_phy_spi.c if using SPI). sendMessage is the workhorse method of the Module library and sends the command to the Module.
 * 3) Next, the sendMessage method creates the array of bytes that will be sent and then calls sendSreq in the same file. This will send the message as a Synchronous Request (SREQ). A SREQ is a message that will be followed by a response message called SRSP.
 * 4) In sendSreq you can see that it asserts CS and MRDY, writes the 3 bytes of the SYS_VERSION command by calling spiWrite.
 * 5) In the hal file, spiWrite sends the bytes out the SPI interface.
 * 6) Since this is a SREQ we need to poll for the SRSP. So, we wait for signal SRDY to go high. This takes ~400uSec.
 * 7) Now that we've sent the SREQ, we read back the response. The method spiSreq reads the received bytes into memory starting at *bytes
 * 8) sendMessage then copies the received bytes into the zmBuf buffer.

Now, in module.c the library method getVersion returns a pointer to the start of the SRSP payload and the main application parses the fields and displays them.

Printing out SPI SREQ Messages and SRSP Responses
If in the Project -> Options... -> C/C++ Category -> Defined Symbols window you define ZM_PHY_SPI_VERBOSE, the SPI message being sent out will be displayed on the serial port.

Additionally, if in the file zm_phy_spi.c you make the following modifications, it will also print out the SRSP received back. In the sendMessage routine, add the following lines immediately below the call to sendSreq: printf("SPI Rx: "); printHexBytes(zmBuf, zmBuf[0] + 3);
 * 1) ifdef ZM_PHY_SPI_VERBOSE
 * 1) endif