The Internet Power Line Adapter - University of Queensland
The Internet Power Line Adapter - University of Queensland
The Internet Power Line Adapter - University of Queensland
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Home Automation, <strong>Power</strong> <strong>Line</strong>s and the <strong>Internet</strong> Quenten Alick<br />
*<br />
* send statistics to host<br />
*/<br />
if (!tbufferInUse) {<br />
tbuffer.functionID = STATS_CMD;<br />
temp[0] = LOW_BYTE_OF(txSuccess);<br />
temp[1] = HIGH_BYTE_OF(txSuccess);<br />
if (recdPkts) {<br />
temp[2] = rxLPDU.LSDU[2];<br />
temp[3] = rxLPDU.LSDU[1];<br />
}<br />
else {<br />
temp[2] = 0;<br />
temp[3] = 0;<br />
}<br />
temp[4] = LOW_BYTE_OF(txRcvValid);<br />
temp[5] = HIGH_BYTE_OF(txRcvValid);<br />
tbuffer.buf = temp;<br />
ResponseToHost(6);<br />
testRunning = FALSE;<br />
}<br />
}<br />
boolean ProcessTransmitEnd( boolean forced )<br />
{<br />
/*<br />
* TRANSMITTING DEVICE:<br />
*<br />
* when forced (as result <strong>of</strong> "query" host command) or<br />
when the running<br />
* transmit counter equals the number <strong>of</strong> host<br />
determined packets, send<br />
* "get count" packet to remote device<br />
*<br />
* return TRUE only if "get count" packet sent to remote<br />
device<br />
*/<br />
if (forced || (txCount == txMax)) {<br />
transmitting = FALSE;<br />
/*<br />
* transmit "get count" packet<br />
*/<br />
if (TxBfrAvailable) {<br />
txLPDU.LPDUheader = txService |<br />
STD_PRIORITY | BASIC_SERVICE;<br />
txLPDU.DA.LSB = 0x02;<br />
txLPDU.DA.MSB = 0x00;<br />
txLPDU.DHC.LSB = config.systemAddr.LSB;<br />
txLPDU.DHC.MSB = config.systemAddr.MSB;<br />
txLPDU.SA.LSB = config.unitAddr.LSB;<br />
txLPDU.SA.MSB = config.unitAddr.MSB;<br />
txLPDU.SHC.LSB = config.systemAddr.LSB;<br />
txLPDU.SHC.MSB = config.systemAddr.MSB;<br />
txLPDU.LSDU[0] = GET_COUNT_PKT;<br />
txLPDU.LPDUlength = CEBUS_HEADER_LEN +<br />
1;<br />
transmitCompleted = FALSE;<br />
TransmitPacket(USE_WTI | USE_DELAY); /*<br />
use WTI command w/ delay */<br />
response_timer = GetVeryLowResTimeByte() +<br />
TWO_SECS;<br />
responseTimerRunning = TRUE;<br />
waitingForLoopback = FALSE;<br />
return TRUE;<br />
} else {<br />
return FALSE;<br />
}<br />
} else {<br />
return FALSE;<br />
}<br />
}<br />
- 57 -<br />
void ProcessValidPacket( void )<br />
{<br />
boolean validCompare; /* comparison flag */<br />
uint8 i; /* local counter */<br />
validCompare = TRUE;<br />
for(i=3;i