robotics/include/comm_config.h File Reference

#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] 
or
 [0x55 0xAA <data> 0xAA 0x55] 
The two inbound header bytes are specified in IN_PACKET_HEADER_1 and IN_PACKET_HEADER_2. The two outbound header bytes are specified in OUT_PACKET_HEADER_1 and OUT_PACKET_HEADER_2.

#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


Detailed Description

Author:
Thomas Donaldson
Take a look at the serial communications (comm) example project in the robotics directory.

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:

  1. Add the comm library files to the project and remember to:
     #include "comm_config.h" 
    
  2. Specify IN_PACKET_SIZE and OUT_PACKET_SIZE. Both must be larger than 4 bytes, since the header and trailer total 4 bytes themselves.
  3. Modify the outbound and inbound packet header and trailer characters, if desired. See IN_PACKET_HEADER_1 for details.
  4. In your start-up code add:
  5. Implement your own
     void divvy_packet(void) 
    

Definition in file comm_config.h.


Define Documentation

#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.


Generated on Sun Mar 15 11:14:22 2009 for PIC24 Support Libraries by  doxygen 1.5.8