For RevB MBED Hardware, with the new boot sequence. This example establishes a transparent link between the mbed USB CDC port and the modem (LISA) 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
Dependencies: C027-REVB UbloxUSBModem mbed
Diff: main.cpp
- Revision:
- 2:c4ad86683060
- Parent:
- 1:15b5edb4a91f
diff -r 15b5edb4a91f -r c4ad86683060 main.cpp --- a/main.cpp Fri Dec 13 23:37:54 2013 +0000 +++ b/main.cpp Sat Dec 14 00:24:59 2013 +0000 @@ -1,93 +1,46 @@ #include "mbed.h" #include "C027.h" -#include "WANDongle.h" -#include "USBSerialStream.h" -#include "UbloxCDMAModemInitializer.h" -#include "UbloxGSMModemInitializer.h" - -DigitalOut mdm_activity(LED); -int main() -{ - int led_toggle_count = 5; +Ticker ticker; +DigitalOut led1(LED); +DigitalOut led2(LED1); +CAN can1(CANRD, CANTD); +Serial pc(USBTX, USBRX); - // the instantiation of the type, calls C027::C027 - C027 c027; - - c027.mdmPower(true,false); - - // enable the GPS, and connect it - // to the m3. - c027.gpsPower(true, false); +char counter = 0; -#if 0 - while(1) { - mdm_activity = !mdm_activity; - wait(0.2); - } -#else - while( led_toggle_count-- > 0 ) - { - mdm_activity = !mdm_activity; - wait(0.2); +void send() { + if(can1.write(CANMessage(1337, &counter, 1))) { + pc.printf("Message sent: %d\r\n", counter); + counter++; } -#endif - - // open the mdm serial port - WANDongle mdmDongle; - USBSerialStream mdmStream(mdmDongle.getSerial(1/* the CDC usually 0 or 1, LISA-C requires CDC1*/)); - USBHost* host = USBHost::getHostInst(); - mdmDongle.addInitializer(new UbloxCDMAModemInitializer(host)); - mdmDongle.addInitializer(new UbloxGSMModemInitializer(host)); - - // open the PC serial port and (use the same baudrate) - Serial pc(USBTX, USBRX); + led1 = !led1; +} + +int main() { + + DigitalOut can_standby(CANS); + + // enable the CAN interface + // take it out of standby + can_standby = 0; + pc.baud(MDMBAUD); - pc.printf( "M3->USB CDC connection ready\n"); - - while (1) - { - uint8_t buf[64]; - size_t len; - int i; - - if (!mdmDongle.connected()) - { - mdmDongle.tryConnect(); + pc.printf( "Starting CAN Testing\r\n"); + + CANMessage msg; + while(1) { + + if(can1.read(msg)) { + pc.printf("Message received: %d\r\n", msg.data[0]); + led2 = !led2; } - else - { - // transfer data from pc to modem - len = mdmStream.space(); - if (len>0) - { - if (len > sizeof(buf)) - len = sizeof(buf); - for (i = 0; (i < len) && pc.readable(); ) - buf[i++] = pc.getc(); - if (OK == mdmStream.write(buf, i)) - /* do something? */; - } - // transfer data from modem to pc - len = mdmStream.available(); - if ((len>0) && pc.writeable()) - { - if (len > sizeof(buf)) - len = sizeof(buf); - if (OK == mdmStream.read(buf, &len, len)) - { - for (i = 0; (i < len); ) - { - mdm_activity=!mdm_activity; - pc.putc(buf[i++]); - } - - // default the led to off - mdm_activity=0; - } - } - } + wait(0.2); + + send(); } } + +