private byte[] BytesFromBuilder(Frame frame) { byte[] bytes; int fixedLength = fixedLengthWithFrameType(frame.type); UInt16 length = (UInt16)(fixedLength + frame.variableDataLength); bytes = new byte[length + 4]; bytes[0] = 0x7E; bytes[1] = ByteOperations.littleEndianBytesFromWord(length)[0]; bytes[2] = ByteOperations.littleEndianBytesFromWord(length)[1]; bytes[3] = (byte)frame.type; bytes[4] = frame.FrameID; switch (frame.type) { case FrameType.RemoteATCommand: setRemoteATCommandRequestValues(bytes, (RemoteATCommandRequestFrame)frame); break; case FrameType.ATCommand: setATCommandRequestValues(bytes, (ATCommandFrame)frame); break; } bytes[fixedLength + 3 + frame.variableDataLength] = checksum(bytes); return bytes; }
public void Enqueue(Frame frame, Callback callback) { if (count == queue.Length) { expandQueue(); } queue[count] = new FrameWithHandler { frame = frame, callback = callback }; count++; }
public ReceivedRemoteFrameEventArgs(Frame frame) { this.frame = frame; }
private void WriteFrame(Frame frame) { byte[] rawFrame = FrameSerializer.Serialize(frame); serialPort.Write(rawFrame, 0, rawFrame.Length); serialPort.Flush(); }
private void OnRecievedFrame(Frame frame) { ReceivedRemoteFrameEventHandler handler = ReceivedRemoteFrame; if (handler != null) { handler(this, frame); } }
private void ReceivedRemoteFrameHandler(object sender, Frame frame) { if (!(frame is DigitalAnalogSampleFrame) || !Frame.isEqualAddress((frame as DigitalAnalogSampleFrame).SourceAddress64Bit, SourceAddress64Bit) || deviceTypeIdentifier == null) { return; } DigitalAnalogSampleFrame sample = frame as DigitalAnalogSampleFrame; for (int i = 0; i < sample.AnalogChannels.Length; ++i) { int pin = sample.AnalogChannels[i]; Widget w = (Widget)pinToWidgetMapping[pin]; if (w != null) { w.RawValue = sample.AnalogSampleData[i]; } } for (int i = 0; i < sample.DigitalChannels.Length; ++i) { int pin = sample.DigitalChannels[i]; Widget w = (Widget)pinToWidgetMapping[pin]; if (w != null) { w.RawValue = sample.DigitalSampleData[pin]; } } onUpdateReceived(); }
public static byte[] Serialize(Frame frame) { return new FrameSerializer().BytesFromBuilder(frame); }
public void onReceivedRemoteFrame(object sender, Frame frame) { if (frame is RemoteATCommandResponseFrame || frame is ATCommandResponseFrame) { ResponseReceived(frame as ATCommandFrame); } }
public void EnqueueFrame(Frame frame, Callback callback) { RequestResponseService.EnqueueFrame(frame, callback); }
void ReceivedRemoteFrameHandler(object sender, Frame frame) { if (!(frame is DigitalAnalogSampleFrame)) { return; } DigitalAnalogSampleFrame sampleFrame = frame as DigitalAnalogSampleFrame; RemoteXBee sourceXBee = null; foreach (RemoteXBee xbee in knownDevices) { if (Frame.isEqualAddress(xbee.SourceAddress64Bit, sampleFrame.SourceAddress64Bit)) { sourceXBee = xbee; } } if (sourceXBee == null) { sourceXBee = new RemoteXBee(sampleFrame.SourceAddress16Bit, sampleFrame.SourceAddress64Bit, null); AddXBee(sourceXBee); } }