public Radio_Series1(Robot robo, string portName)
        {
            robot = robo;
            UIAnalogVals = new int[(int)INTERFACEPACKET.ANALOG_BYTES];
            UIDigitalVals = new bool[(int)INTERFACEPACKET.DIGITAL_BYTES * 8];

            state = RadioState.IDLE;
            port = new SerialPort(portName, 9600, Parity.None, 8, StopBits.One);
            port.ReadTimeout = 2;
            port.Open();

            data = new InterfacePacket((byte)INTERFACEPACKET.IDENT, (int)INTERFACEPACKET.ANALOG_BYTES, (int)INTERFACEPACKET.DIGITAL_BYTES);
            telemetry = new TelemetryPacket((byte)TELEMETRYPACKET.IDENT, (int)TELEMETRYPACKET.ANALOG_BYTES, (int)TELEMETRYPACKET.DIGITAL_BYTES);
            buffer = new byte[512];
            receiver = new XBeeInterfaceReceiver(this);

            frame = 0;
        }
示例#2
0
        private XBeeInterfaceReceiver receiver; /** Parses the packet received by the XBee and pulls the data out. */

        #endregion Fields

        #region Constructors

        /** Constructor for the Radio class.
         *  @param port The name of the port for the radio to listen and send data on. */
        public Radio(string portName)
        {
            port = new SerialPort(portName, 57600, Parity.None, 8, StopBits.One); // baud rate second argument for SerialPort, try 57600, 19200, 38400, 57600
            port.ReadTimeout = 2; // 2 milliseconds, very short read timeout (default is 500)
            port.Open();

            buffer = new byte[512];
            receiver = new XBeeInterfaceReceiver(this);
            inData = new IncomingData((byte)INCOMING_DATA.IDENT, (int)INCOMING_DATA.ANALOG_BYTES, (int)INCOMING_DATA.DIGITAL_BYTES);
            outData = new OutgoingData((byte)OUTGOING_DATA.IDENT, (int)OUTGOING_DATA.ANALOG_BYTES, (int)OUTGOING_DATA.DIGITAL_BYTES);

            UIAnalogVals = new int[(int)INCOMING_DATA.ANALOG_BYTES];
            UIDigitalVals = new bool[(int)OUTGOING_DATA.DIGITAL_BYTES * 8];
            frame = 0;
        }