Serial Communication Code - Troubleshooting with a PC Serial Emulator

26 Feb 2017

Hello,

I'm trying to ultimately be able to send an integer value of 45 with the below code using a uart serial port. To see if data is being sent to the uart, I'm trying to check using a serial emulator program (Terminal), but in compiling the below code, I get the following two error messages:

Error: Symbol pc multiply defined (by mbed_genie.NUCLEO_F302R8.o and main.NUCLEO_F302R8.o). Error: Not enough information to list the image map.

What do I need to do to resolve this?

Thanks a lot, Neil

  1. include "mbed.h"

Serial pc(USBTX,USBRX); Serial uart(D1,D0, 9600);set tx and rx on the mbed DigitalOut leddata(LED1); void sendInt( int numberToSend ) { char *dataStart = (char *) &numberToSend;

for (int i = 0; i < sizeof(int); i++) { pc.putc( *(dataStart + i) ); } } handles data send

int main() {

while (1) {

if (pc.writeable()) { int datavalue = 45;/could change to include the H1/DC value in future (from ventilator) if this sendInt(datavalue); } } }

01 Mar 2017

It could be that this is an error coming from the mbed library as the error message mentions the files mbed_genie.NUCLEO_F302R8.o and main.NUCLEO_F302R8.o

You could try to add another board to your compiler, for example a nucleo F746ZF and try to compile your sketch again. If it compiles successfully, this is a bug in the library part that is for your special board.

11 Mar 2017

Hello Neil,
When I use the online compiler and select NUCLEO-F302R8 as target board your code compiles without errors . Based on the error messages you have got I would guess you imported a library into your project which contains an mbed_genie.cpp file defining a global symbol called pc colliding with the name of the Serial object you defined in your main code. The solution could be either to delete the external library from your project (seems you don't use it anyway) or to change the name of the Serial object from pc to some different name (e.g. terminal).

NOTE: When you publish a code then adding <<code>> and <</code>> tags as below will make it more readable:

<<code>>
#include "mbed.h"

Serial pc(USBTX,USBRX);

//handles data send
void sendInt( int numberToSend )
{
    char *dataStart = (char *) &numberToSend;

    for (int i = 0; i < sizeof(int); i++) {
        pc.putc( *(dataStart + i) );
    }
}

int main()
{
    while (1) {
        if (pc.writeable()) {
            int datavalue = 45;
            //could change to include the H1/DC value in future (from ventilator)
            sendInt(datavalue);
        }
    }
}
<</code>>