beautypg.com

Echelon ISI User Manual

Page 86

background image

ISI Programmer’s Guide

84

request.Msg.Rdct.Index = recoveryJob.index++;
request.Msg.Rdct.Host = request.Msg.Rdct.Member = ISI_NO_ASSEMBLY;

destination.nrnid.type = NEURON_ID;
destination.nrnid.domain = PRIMARY_DOMAIN;
destination.nrnid.rpt_timer = ENCODED_RPT_TIMER;
destination.nrnid.subnet = 0;

destination.nrnid.retry = RETRY_COUNT;
destination.nrnid.tx_timer = ENCODED_TX_TIMER;
memcpy(destination.nrnid.nid, recoveryJob.neuronId, NEURON_ID_LEN);

IsiMsgSend(&request, sizeof(IsiMessageHeader)+sizeof(IsiRdct), REQUEST,
&destination);
}

// Handle receipt of incoming responses. This example focusses on
// isiRdcs and isiRdcf responses.
when (resp_arrives) {
IsiMessage response;
if (resp_in.code == isiApplicationMessageCode) {

// This is an ISI response
memcpy(&response, resp_in.data, resp_in.len);
if (response.Header.Code == isiRdcf) {
// The remote device rejected our request, probably because we

// have queried all available connection table entries already

// (bad index). Notify the user interface, if needed.

...

} else if (response.Header.Code == isiRdcs) {
// The remote device replied to our request with the connection

// table entry requested, in response.Msg.Rdcs. Notify the UI

// and/or process this data further, as needed by the application:

...


// Because we received a positive response, let's try for the

// next index

RequestConnectionTable();
}
}
}

// Initiate the process of reading a remote device's connection table.
// The function kick-starts the process, where the majority of the work
// is done in the when (resp_arrives) task. Calling this function before
// the previous connection table read job completes causes the previous

// job to abort, and the new one to start
void ReadRemoteConnectionTable(const unsigned* remoteNeuronId) {
memcpy(recoveryJob.neuronId, remoteNeuronId, NEURON_ID_LEN);
recoveryJob.index = 0;
RequestConnectionTable();
}

E

XAMPLE

2

The following ISI device example receives a read connection table request

(RDCT) message and then sends the appropriate response.

#pragma num_alias_table_entries 6

#include

// Reply with isiRdcf (connection table read failure), or with
// isiRdcs (connection table read success) message for the