This example establishes a transparent link between the mbed serial port and the modem (LISA or SARA) on the C027. You can use it to use the standard u-blox tools such as m-center or any terminal program. These tools can then connect to the serial port and talk directly to the modem. Baudrate should be set to 115200 baud and is fixed. m-center can be downloaded from u-blox website following this link: http://www.u-blox.com/en/evaluation-tools-a-software/u-center/m-center.html
Fork of C027_ModemTransparentSerial by
main.cpp@1:7334dcb895d0, 2013-10-23 (annotated)
- Committer:
- mazgch
- Date:
- Wed Oct 23 06:12:48 2013 +0000
- Revision:
- 1:7334dcb895d0
- Parent:
- 0:53fc79c7af10
- Child:
- 2:1970ac045983
fixed pinname
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mazgch | 0:53fc79c7af10 | 1 | #include "mbed.h" |
mazgch | 0:53fc79c7af10 | 2 | #include "C027_PinNames.h" |
mazgch | 0:53fc79c7af10 | 3 | |
mazgch | 0:53fc79c7af10 | 4 | int main() |
mazgch | 0:53fc79c7af10 | 5 | { |
mazgch | 0:53fc79c7af10 | 6 | // open the mdm serial port |
mazgch | 0:53fc79c7af10 | 7 | Serial mdm(MDMTXD, MDMRXD); |
mazgch | 0:53fc79c7af10 | 8 | mdm.baud(MDMBAUD); |
mazgch | 0:53fc79c7af10 | 9 | // tell the modem that we can always receive data |
mazgch | 1:7334dcb895d0 | 10 | DigitalOut mdmRts(MDMRTS); |
mazgch | 0:53fc79c7af10 | 11 | mdmRts = 0; // (not using flow control) |
mazgch | 0:53fc79c7af10 | 12 | |
mazgch | 0:53fc79c7af10 | 13 | // open the PC serial port and (use the same baudrate) |
mazgch | 0:53fc79c7af10 | 14 | Serial pc(USBTX, USBRX); |
mazgch | 0:53fc79c7af10 | 15 | pc.baud(MDMBAUD); |
mazgch | 0:53fc79c7af10 | 16 | |
mazgch | 0:53fc79c7af10 | 17 | while (1) |
mazgch | 0:53fc79c7af10 | 18 | { |
mazgch | 0:53fc79c7af10 | 19 | // transfer data from pc to modem |
mazgch | 0:53fc79c7af10 | 20 | if (pc.readable() && mdm.writeable()) |
mazgch | 0:53fc79c7af10 | 21 | mdm.putc(pc.getc()); |
mazgch | 0:53fc79c7af10 | 22 | // transfer data from modem to pc |
mazgch | 0:53fc79c7af10 | 23 | if (mdm.readable() && pc.writeable()) |
mazgch | 0:53fc79c7af10 | 24 | pc.putc(mdm.getc()); |
mazgch | 0:53fc79c7af10 | 25 | } |
mazgch | 0:53fc79c7af10 | 26 | } |