*/
#include "mbed.h"
// Maximum number of element the application buffer can contain
#define MAXIMUM_BUFFER_SIZE 32
// Create a DigitalOutput object to toggle an LED whenever data is received.
static DigitalOut led(LED1);
// Create a BufferedSerial object with a default baud rate.
static BufferedSerial serial_port(USBTX, USBRX);
int main(void)
{
// Set desired properties (9600-8-N-1).
serial_port.set_baud(9600);
serial_port.set_format(
/* bits */ 8,
/* parity */ BufferedSerial::None,
/* stop bit */ 1
);
// Application buffer to receive the data
char buf[MAXIMUM_BUFFER_SIZE] = {0};
while (1) {
if (uint32_t num = serial_port.read(buf, sizeof(buf))) {
// Toggle the LED.
led = !led;
// Echo the input back to the terminal.
serial_port.write(buf, num);
}
}
}
I am not able to see any echo even though I send some data through the serial port with Putty.
I also checked serial_port.readable() and it never triggers.
I am not sure how to proceed forward. I only want to use buffered serial.
I normally not use Putty but it looks like you need to change some settings.
Just try to run your app and before open a session change the Local echo: and Local line Editing: to Force ON in the Terminal settings.
@parthsagar2010
Use UnbufferedSerial instead if you can or avoid maxim boards in general.
The MAX32630FTHR has noticable HW specs but produces a bunch of different weird things.
I am sure MAXIM has some software engineers but they are either totally uncapable or they just abandonned mbed withot communicating it.
But for sure neither Mbed core team, nor Maxim have any quality assurance. That is why the mbed website still states this board is mbed V6.3 compatible despite it is not.
Actually up until V5.9.7 the board is usable, but that mbed version is so ancient you can not even find its documentation on the mbed website, nor can you select that mbed version in the online compiler or in mbed Studio.
Your code example works on an NUCLEO-F401RE board using OS 6.3. I’m using PuTTY with 9600,8,N,1 with local echo set to “force off” (after all, we are expecting the CPU to send back the character we send to it) The LED on the board flashes on/off in a cycle for each keypress I put into PuTTY. I would suspect that mbed has a bug with supporting that MCU…
Yes, I guess MAX32630 has some compatibility issues with MBED. I cant even make the simple SD card example make it work . (SD Card File System - Cookbook | Mbed)
Somehow I was able to solve the issue by using the second example in BufferedSerial page by adding the following
Firstly you found the SDFileSystem library written for Mbed OS 2, that might not work in Mbed OS 5 or 6 (actually SD card functionality has been merged into core somewhere around V5.10 if i remember right). So on recent versions you do not need to include any libraries.
Secondly the board has an on-board SD card slot, but in targets.json it is simply not defined. As a consequence Mbed does not know that this board could handle any SD relevant stuff.
Posted about it several times, but nobody seems to care.
I am not able to find the mbed_app.json file in the online workspace. My goal is to make the SDBlockDevice work with latest MBed OS so that I can merge it with my existing code.