//////////////////////////////////////////////////////////////////////// // Main Task //////////////////////////////////////////////////////////////////////// task main() { eraseDisplay(); bNxtLCDStatusDisplay = true; setupHighSpeedLink(); //This is the buffer that will hold the bytes to transmit. ubyte testBytes[1]; int xmitCount = 1; nMotorEncoder[motorB] = 0; // Reset the Motor Encoder of Motor B. //The test will continue until an error occurs or //the enter button on the brick is pressed. while(nNxtButtonPressed != kEnterButton) { eraseDisplay(); int motorposn = nMotorEncoder[motorB]; //This will display the the motor position. nxtDisplayTextLine(1, (string)motorposn + " XMIT"); //Set the bytes of the buffer to the next byte. testBytes[0] = motorposn; //Transmit the bytes. int retVal = TransmitBytes(testBytes, sizeof(testBytes)); //Format the byte string and display it. string tStr0; StringFormat(tStr0, "%3d", testBytes[0]); string TempStr = tStr0; nxtDisplayTextLine(2, TempStr); //Delay. Possibly, this could be used for an ACK. wait1Msec(MS_TO_DELAY); } }
void MANCHESTERClass::Transmit(unsigned int data) { unsigned char byteData[2] = {data >> 8, data & 0xFF}; TransmitBytes(2, byteData); }
void TransmitCString(cString *s) { TransmitBytes((char *)&s->length, sizeof(s->length)); TransmitBytes(s->string, s->length); }
void SendTransportMessage(TransportMessage *tpMessage) { TransmitBytes((uint8_t *)&tpMessage->reserved, sizeof(tpMessage->reserved)); TransmitBytes((uint8_t *)&tpMessage->size, sizeof(tpMessage->size)); TransmitBytes((uint8_t *)tpMessage->data, tpMessage->size); }