
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@4:e089bc72b28c, 2013-12-13 (annotated)
- Committer:
- dixter1
- Date:
- Fri Dec 13 23:38:22 2013 +0000
- Revision:
- 4:e089bc72b28c
- Parent:
- 2:1970ac045983
- Child:
- 5:1f5bb69f15d5
Updated
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mazgch | 0:53fc79c7af10 | 1 | #include "mbed.h" |
mazgch | 2:1970ac045983 | 2 | #include "C027.h" |
mazgch | 0:53fc79c7af10 | 3 | |
dixter1 | 4:e089bc72b28c | 4 | DigitalOut mdm_activity(LED); |
dixter1 | 4:e089bc72b28c | 5 | |
mazgch | 0:53fc79c7af10 | 6 | int main() |
mazgch | 0:53fc79c7af10 | 7 | { |
dixter1 | 4:e089bc72b28c | 8 | int led_toggle_count = 5; |
dixter1 | 4:e089bc72b28c | 9 | |
mazgch | 2:1970ac045983 | 10 | C027 c027; |
dixter1 | 4:e089bc72b28c | 11 | |
dixter1 | 4:e089bc72b28c | 12 | // enable, and use the uart |
dixter1 | 4:e089bc72b28c | 13 | c027.mdmPower(true,true); |
dixter1 | 4:e089bc72b28c | 14 | |
dixter1 | 4:e089bc72b28c | 15 | // enable the GPS. |
dixter1 | 4:e089bc72b28c | 16 | c027.gpsPower(true); |
mazgch | 2:1970ac045983 | 17 | |
dixter1 | 4:e089bc72b28c | 18 | #if 0 |
dixter1 | 4:e089bc72b28c | 19 | while(1) { |
dixter1 | 4:e089bc72b28c | 20 | mdm_activity = !mdm_activity; |
dixter1 | 4:e089bc72b28c | 21 | wait(0.2); |
dixter1 | 4:e089bc72b28c | 22 | } |
dixter1 | 4:e089bc72b28c | 23 | #else |
dixter1 | 4:e089bc72b28c | 24 | while( led_toggle_count-- > 0 ) |
dixter1 | 4:e089bc72b28c | 25 | { |
dixter1 | 4:e089bc72b28c | 26 | mdm_activity = !mdm_activity; |
dixter1 | 4:e089bc72b28c | 27 | wait(0.2); |
dixter1 | 4:e089bc72b28c | 28 | } |
dixter1 | 4:e089bc72b28c | 29 | #endif |
dixter1 | 4:e089bc72b28c | 30 | |
mazgch | 0:53fc79c7af10 | 31 | // open the mdm serial port |
mazgch | 0:53fc79c7af10 | 32 | Serial mdm(MDMTXD, MDMRXD); |
mazgch | 0:53fc79c7af10 | 33 | mdm.baud(MDMBAUD); |
mazgch | 0:53fc79c7af10 | 34 | // tell the modem that we can always receive data |
mazgch | 1:7334dcb895d0 | 35 | DigitalOut mdmRts(MDMRTS); |
mazgch | 0:53fc79c7af10 | 36 | mdmRts = 0; // (not using flow control) |
mazgch | 0:53fc79c7af10 | 37 | |
mazgch | 0:53fc79c7af10 | 38 | // open the PC serial port and (use the same baudrate) |
mazgch | 0:53fc79c7af10 | 39 | Serial pc(USBTX, USBRX); |
mazgch | 0:53fc79c7af10 | 40 | pc.baud(MDMBAUD); |
mazgch | 0:53fc79c7af10 | 41 | |
dixter1 | 4:e089bc72b28c | 42 | pc.printf( "M3->UART connection ready\r\n"); |
dixter1 | 4:e089bc72b28c | 43 | |
mazgch | 0:53fc79c7af10 | 44 | while (1) |
mazgch | 0:53fc79c7af10 | 45 | { |
mazgch | 0:53fc79c7af10 | 46 | // transfer data from pc to modem |
mazgch | 0:53fc79c7af10 | 47 | if (pc.readable() && mdm.writeable()) |
mazgch | 0:53fc79c7af10 | 48 | mdm.putc(pc.getc()); |
mazgch | 0:53fc79c7af10 | 49 | // transfer data from modem to pc |
dixter1 | 4:e089bc72b28c | 50 | if (mdm.readable() && pc.writeable()) |
mazgch | 0:53fc79c7af10 | 51 | pc.putc(mdm.getc()); |
mazgch | 0:53fc79c7af10 | 52 | } |
mazgch | 0:53fc79c7af10 | 53 | } |