Transmitting

[At master]

BYTE Srbuf[10];

 

Cmd[0] = 2;                        //The number of listeners + 1 (here, there is one listener)

Cmd[1] = TalkerAdrs;               //The address of device that sends data (own address)

Cmd[2] = ListenerAdrs;             //The address of device that receives data

Ret = GpTalk(Cmd, Srlen, Srbuf);   //Srlen = data length: Srbuf = buffer that stores data

 

[At slave]

Ex. 1: The transmitting operation starts after checking the talker designation from the master.
This implementation is recommended to match the communication timing with the master.

DWORD   Ret, SendLen, Cmd[10], TAreg;

char    SendBuf[10];

do{

    Ret = GpBoardstsEx(0, 0x13, &TAreg); // Confirms talker is specified.

    if(Ret != 0) return;                 // Checks return code.

}while(TAreg == 0);                      // Loops until talker is specified.

Cmd[0] = 0;                              // Indicates no multi line message.

strcpy(SendBuf, "Hello" );               // Sets data to transmit to "Hello".

SendLen = strlen(SendBuf);               // Retrieves number of transfer string from data to transmit.

Ret = GpTalk(Cmd, SendLen, SendBuf);     // Transmits to master.

 

Ex. 2: Transmitted without checking the talker designation from the master.

BYTE Srbuf[10];

 

Cmd[0] = 0;                        //Indicates no multi line message

Ret = GpTalk(Cmd, Srlen, Srbuf);   //Srlen = data length: Srbuf = buffer that stores data

 

Notes

To send data, writing a terrible program may be needed, actually it can be done in several lines of code.
As a flow, it is required only to specify the master, listener and data to be sent. At first, creates a array.

Cmd[0] = 2;               //The number of listeners + 1 (here, there is one listener)

Cmd[1] = TalkerAdrs;      //The address of device that sends data (own address)

Cmd[2] = ListenerAdrs;    //The address of device that receives data

If there are two listeners, adds Cmd[3], and sets Cmd[0] to 3.

Next, uses the GpTalk function to send data.
GpTalk function is described as follows.

GpTalk(Cmd, Srlen, Srbuf);

Specifies the beginning address of the Cmd array for the first parameter of the GpTalk function.

Please make sure that the value of Srlen must not exceed the number of data in Srbuf (the number of bytes).
If exceeded, invalid data may be sent to the destination device, and the program operation may be unexpected.

 

Notes on the master side:

If you attempt to send or receive data from the master side when a slave device is measuring, communication processing may not be performed correctly.
In general, slave devices have a function that issues an SRQ request to the master when a time-consuming process is completed.

In this case, we recommend that the master side wait for an SRQ request before sending or receiving data.