Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 5 months ago.
Problem with RS232 / sendig / reception
Hello,
Here is my mbed code
#include "mbed.h" //------------------------------------ // Hyperterminal configuration // 9600 bauds, 8-bit data, no parity //------------------------------------ Serial pc(SERIAL_TX, SERIAL_RX); //Declaration de la liaison RS232 sigfox Serial sigfox(PC_12, PD_2); int main() { char c; while(1) { if(pc.readable()) { c = pc.getc(); sigfox.putc(c); } if(sigfox.readable()) { pc.putc(sigfox.getc()); } } }
My problem is, when I send a character from my PC, it is not send to sigfox but to my PC
I'm using STM32 Nucleo L476RG
Any ideas ?
Thanks
2 Answers
7 years, 5 months ago.
Maybe the sigfox does receive the data and echoes it back to mbed which then returns it to the PC making it look as if the data never reaches sigfox.
7 years, 5 months ago.
Your code looks logically correct. However I might suggest some changes which you can try and see if it works correctly Note the use of RawSerial and sigfox.writeable, pc.writeable.
#include "mbed.h" //------------------------------------ // Hyperterminal configuration // 9600 bauds, 8-bit data, no parity //------------------------------------ RawSerial pc(SERIAL_TX, SERIAL_RX); //Declaration de la liaison RS232 sigfox RawSerial sigfox(PC_12, PD_2); int main() { char c; while(1) { if(pc.readable()) { c = pc.getc(); while(!sigfox.writeable()); sigfox.putc(c); } if(sigfox.readable()) { c = sigfox.getc(); while(!pc.writeable()); pc.putc(c); } } }