Need some help to get my C++ program to interface Arduino boards

Hi, I am modifying a C++ program so that it can communicate with 4 Arduino boards that are used as output boards to LEDS etc.

I have imported SerialClass.h and Serial.cpp to my C++ program.

In one of my C++ module( client.cpp) when I have the

Serial* SP1 = new Serial("\\.\COM3");
Serial* SP2 = new Serial("\\.\COM4");
Serial* SP3 = new Serial("\\.\COM5");
Serial* SP4 = new Serial("\\.\COM6");

declared in the beginng of client.cpp, everything is OK. My function for sending data works fine over all 4 serial ports to the 4 Arduinos.

This solution is only working well in my development setup, as I know the COM ports that are used by the Arduinos on my PC. But, I need a solution that is not hardcoded as the COM port used by other users will be different. Therefore I have a function in client.cpp that reads the COM port numbers from an .ini file that has been set by the user.

When I run my function with i.e.

Serial* SP1 = new Serial("\\.\COM9"); ( the COM9 is read from the .ini file)

the pointer is set to NULL;

ANy ideas what is going wrong

Serial.cpp (3.67 KB)

SerialClass.h (1.07 KB)

Hi,

I just sorted this out myself. Mu problem was that I declared the pointer again, not just adding the address to the already declared pointer.

it should have been

SP1 = new Serial("\\.\COM9");

SOLVED