I am no longer actively working on the ppCANOpen library, however, I want to publish this project so that anyone who wants to pick up any of the pieces can have a good example. This is a a project I was working on using the ppCANOpen library. It has a pretty in deep use of the object dictionary structure. And a number of functions to control high voltage pinball drivers, if you're into that sort of thing.

Dependencies:   CANnucleo mbed ppCANOpen

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SerialBuffered.h Source File

SerialBuffered.h

00001 #ifndef _SERIAL_BUFFERED_H_
00002 #define _SERIAL_BUFFERED_H_
00003 
00004 /**
00005  * Buffered serial class.
00006  */
00007 class SerialBuffered : public Serial {
00008 public:
00009     /**
00010      * Create a buffered serial class.
00011      *
00012      * @param tx A pin for transmit.
00013      * @param rx A pin for receive.
00014      */
00015     SerialBuffered(PinName tx, PinName rx);
00016 
00017     /**
00018      * Destroy.
00019      */
00020     virtual ~SerialBuffered();
00021 
00022     /**
00023      * Get a character.
00024      *
00025      * @return A character. (-1:timeout)
00026      */
00027     int getc();
00028 
00029     /**
00030      * Returns 1 if there is a character available to read, 0 otherwise.
00031      */
00032     int readable();
00033 
00034     /**
00035      * Set timeout for getc().
00036      *
00037      * @param ms milliseconds. (-1:Disable timeout)
00038      */
00039     void setTimeout(int ms);
00040 
00041     /**
00042      * Read requested bytes.
00043      *
00044      * @param bytes A pointer to a buffer.
00045      * @param requested Length.
00046      *
00047      * @return Readed byte length.
00048      */
00049     size_t readBytes(uint8_t *bytes, size_t requested);
00050 
00051 private:
00052     void handleInterrupt();
00053     static const int BUFFERSIZE = 2048;
00054     uint8_t buffer[BUFFERSIZE];            // points at a circular buffer, containing data from m_contentStart, for m_contentSize bytes, wrapping when you get to the end
00055     uint16_t indexContentStart;   // index of first bytes of content
00056     uint16_t indexContentEnd;     // index of bytes after last byte of content
00057     int timeout;
00058     Timer timer;
00059 };
00060 
00061 #endif