Zhengyang Gu / Mbed 2 deprecated C027_ModemTransparentSerial_BBB

Dependencies:   mbed

Fork of C027_ModemTransparentSerial by u-blox

main.cpp

Committer:
mazgch
Date:
2013-12-19
Revision:
5:1141d3cfd1ef
Parent:
4:fafdcaf842ee
Child:
6:1e5c9b6b2e90

File content as of revision 5:1141d3cfd1ef:

#include "mbed.h"
#include "C027.h"

int main() 
{
    C027 c027;
    c027.mdmPower(true);
    
    // open the mdm serial port
    Serial mdm(MDMTXD, MDMRXD);
    mdm.baud(MDMBAUD);
    // use hardware flow control to make the connection more reliable
    mdm.set_flow_control(SerialBase::RTSCTS, MDMRTS, MDMCTS);
    
    // open the PC serial port and (use the same baudrate)
    Serial pc(USBTX, USBRX);
    pc.baud(MDMBAUD);
    
    while (1)
    {
        // transfer data from pc to modem
        if (pc.readable() && mdm.writeable())
            mdm.putc(pc.getc());
        // transfer data from modem to pc
        if (mdm.readable() && pc.writeable())
            pc.putc(mdm.getc());
    }
}