11 years, 8 months ago.

regarding printf function in vodafone usb modem

sir when i execute the following serial port program its working fine

#include "mbed.h"
 
Serial pc(p9, p10); // tx, rx
 
int main() {
    
    pc.baud(9600);
    pc.printf("Hello World!\n");
    while(1) ;
}

i want to use the vodafone usbmodem (for internet) hello world program.in that program, in multiple files printf funtion is used for debugging.when i placed the same code in mbed and connected vodafone no messages are printed on hyperterminal. how to make working this printf function in the hello world program

Thanks in advance uday

1 Answer

11 years, 8 months ago.

I'm not sure which VodafoneUSBModem example in particular you're looking at, but I took a quick look through a few and see that it is using code like...

printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());

The use of printf rather than Serial.printf means that the output will go over the mbed's USB connection, you can connect a terminal to the comm port of the mbed. You can find some examples of this on the SerialPC handbook page it may be necessary to install a driver to use the USB serial port.

actually i have purchased mbed xpressoboard and mbed board.i placed my mbed board on xpressoboard(from NGX technologies).i have written the following code

#include "mbed.h"
Serial pc(p9, p10); tx, rx

int main() {

pc.baud(9600); pc.printf("Hello World!\n"); while(1) ; }

through rs-232 cable on hyper terminal i got the output as hello wolrd.so my mbed and xpresso board is working fine.

if i place the code following code 
#include "mbed.h"
 
int main() {
    printf("Hello World!\n");
}

printf function is not working that means printf function from stdio.h is not linking with my code.how to link printf function because in all the examples printf function is used as a debugging tool

Thank you uday

posted by uday kumar 13 Mar 2013

My apologies I think I have misread your original question.

posted by Stephen Paulger 13 Mar 2013

I have updated my answer.

posted by Stephen Paulger 13 Mar 2013