#include "esos.h"
#include "esos_pic24.h"
#include "esos_pic24_rs232.h"
#include <string.h>
#include "comm.h"
Go to the source code of this file.
Defines | |
#define | IN_PACKET_SIZE 18 |
#define | OUT_PACKET_SIZE 19 |
Framing Configuration | |
Communication traffic should be framed with a header and trailer in order to assure synchronization and increase reliability. Inbound and outbound packets are framed with a 2-byte header and trailer with the trailer being a flipped version of the header. A visual example of the default packet: [H1 H2 <payload> T1 T2] [0x55 0xAA <data> 0xAA 0x55] | |
#define | IN_PACKET_HEADER_1 0x55 |
#define | IN_PACKET_HEADER_2 0xAA |
#define | OUT_PACKET_HEADER_1 0x66 |
#define | OUT_PACKET_HEADER_2 0xBB |
#define | IN_PACKET_TRAILER_1 IN_PACKET_HEADER_2 |
#define | IN_PACKET_TRAILER_2 IN_PACKET_HEADER_1 |
#define | OUT_PACKET_TRAILER_1 OUT_PACKET_HEADER_2 |
#define | OUT_PACKET_TRAILER_2 OUT_PACKET_HEADER_1 |
It is recommended to copy the comm library files (both .c and .h) over to the local project directory. This allows for editing comm_config.h without affecting the library.
This header file serves as the main point of configuration of the comm subsystem library. In order to tailor the comm library for your needs:
#include "comm_config.h"
void divvy_packet(void)
Definition in file comm_config.h.
#define IN_PACKET_HEADER_1 0x55 |
In conjunction with IN_PACKET_HEADER_2, this is used by the PIC to determine the beginning of a valid packet. From the framing convention, this also becomes the last byte expected in the inbound packet trailer.
Definition at line 72 of file comm_config.h.
#define IN_PACKET_HEADER_2 0xAA |
In conjunction with IN_PACKET_HEADER_1, this is used by the PIC to determine the beginning of a valid packet. From the framing convention, this also becomes the first byte expected in the inbound packet trailer.
Definition at line 79 of file comm_config.h.
#define IN_PACKET_SIZE 18 |
This specifies the total expected size of the inbound packet. This should include the 2-byte header and 2-byte trailer. For example, if you expect to send the PIC a 3-byte packet payload, then IN_PACKET_SIZE will be 2 + 3 + 2 = 7.
Definition at line 40 of file comm_config.h.
#define OUT_PACKET_HEADER_1 0x66 |
In conjunction with OUT_PACKET_HEADER_2, this is placed as the first byte of the outbound packet header. From the framing convention, this also becomes the last byte in the outbound packet trailer.
Definition at line 86 of file comm_config.h.
#define OUT_PACKET_HEADER_2 0xBB |
In conjunction with OUT_PACKET_HEADER_1, this is placed as the second byte of the outbound packet header. From the framing convention, this also becomes the first byte in the outbound packet trailer.
Definition at line 93 of file comm_config.h.
#define OUT_PACKET_SIZE 19 |
This specifies the total expected size of the outbound packet. This should include the 2-byte header and 2-byte trailer. For example, if you expect to send the PC a 7-byte packet payload with an error byte, then OUT_PACKET_SIZE will be 2 + 1 + 7 + 2 = 12.
Definition at line 48 of file comm_config.h.