Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * AX.25 protocol frame structure:
- * -------------------------------
- *
- * Flag Field: 8 bits (1 byte)
- * Header Field: 128 bits (16 bytes)
- * {
- * Destination Address: 56 bits (7 bytes)
- * Source Address: 56 bits (7 bytes)
- * Control Bits : 8 bits (1 byte )
- * Protocol Identifier: 8 bits (1 byte )
- * }
- * Data Field: 32-2048 bits (4-256 bytes)
- * Frame Checksum Field: 16 bits (2 bytes)
- * Flag Field: 8 bits (1 byte)
- *
- */
- unsigned char AX25_Flag;
- unsigned char AX25_Header[16] = {0};
- unsigned char AX25_Data[256] = {0};
- unsigned char AX25_CheckSum[2] = {0};
- int inByte = 0;
- void setup()
- {
- // Serial1 : TX pin 18, RX pin 19
- // Serial2 : TX pin 16, RX pin 17
- // Serial1 will receive data from a device and resend it on Serial2 using AX25 protocol format
- Serial1.begin(9600);
- Serial2.begin(9600);
- }
- void loop()
- {
- // Wait until data is received on Serial1 port
- while ( !(Serial1.available()) );
- // Read received data
- inByte = Serial1.read();
- // Send the data using AX.25 protocol format
- AX25_Data[0] = (unsigned char) inByte & 0xFF;
- Serial2.write(AX25_Flag);
- Serial2.write(AX25_Header, 16);
- Serial2.write(AX25_Data, 256);
- Serial2.write(AX25_CheckSum, 2);
- Serial2.write(AX25_Flag);
- delay(500);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement