A library for talking to Multi-Tech's Cellular SocketModem Devices.

Dependents:   M2X_dev axeda_wrapper_dev MTS_M2x_Example1 MTS_Cellular_Connect_Example ... more

io/MTSBufferedIO.h

Committer:
jengbrecht
Date:
2013-12-09
Revision:
0:563b70517320
Child:
17:2d7c4ea7491b

File content as of revision 0:563b70517320:

#ifndef MTSBUFFEREDIO_H
#define MTSBUFFEREDIO_H

#include "mbed.h"
#include "MTSCircularBuffer.h"

class MTSBufferedIO
{
public:
    MTSBufferedIO(int txBufferSize = 128, int rxBufferSize = 128);
    ~MTSBufferedIO();

    int write(char* data, int length);
    int write(char data);
    int read(char* data, int length);
    int read();

    template<typename T>
    void attach(T *tptr, void(T::*mptr)(void), int threshold, Vars::RelationalOperator op, Serial::IrqType type);
    
    void attach(void(*fptr)(void), int threshold, Vars::RelationalOperator op, Serial::IrqType type);

    bool txEmpty();
    bool rxEmpty();
    bool txFull();
    bool rxFull();
    void txClear();
    void rxClear();
    int txAvailable();
    int rxAvailable();
    int txCapacity();
    int rxCapacity();

    virtual void handleWrite() = 0;
    virtual void handleRead() = 0;

protected:
    MTSCircularBuffer* txBuffer;
    MTSCircularBuffer* rxBuffer;
};

#endif /* MTSBUFFEREDIO_H */