How to send multiple values in string through serial port

Hello everyone, im having a small problem of how to send multiple values stored in variables via string.
“02 00 V_MSB V_LSB C_MSB C_LSB 03” this is the value which i want to send thorugh serial port in the string format.
Also the V_MSB V_LSB C_MSB and C_LSB have some values in it too. is it possible to send those values in string?

#include <Wire.h>
#include <MCP342X.h>

MCP342X myADC;
const int outpin=A0;
static int16_t result;

int V_MSB,V_LSB,C_MSB,C_LSB;
const String tset1=‘02 00 V_MSB V_LSB C_MSB C_LSB 03’;// have to send this value in format of string

const byte NUM_COMMANDS = 4;
const byte COMMAND_SIZE = 4;
char incomingdata[NUM_COMMANDS];

// array with all incoming commands
const char commands[COMMAND_SIZE] = {
{2,‘0’,‘1’,3}
,{2,‘0’,‘2’,3}
,{2,‘0’,‘3’,3}
,{2,‘0’,‘6’,3}
};

// commands to send
int T=V_MSB;
const char *sendStr[NUM_COMMANDS] = {“tset1”, “tset2”, “test3”, “tset4”};

void setup()
{
Serial.begin(115200);
pinMode(outpin,INPUT);
Wire.begin();
while (!Serial)
{
}
Serial.println(“Starting up”);
Serial.println(“Testing device connection…”);
Serial.println(myADC.testConnection() ? “MCP342X connection successful” : “MCP342X connection failed”);
myADC.configure( MCP342X_MODE_CONTINUOUS |
MCP342X_CHANNEL_1 |
MCP342X_SIZE_16BIT |
MCP342X_GAIN_1X
);
Serial.println(myADC.getConfigRegShdw(), HEX);
}

void loop()
{
adc_output();
if(Serial.available()>=COMMAND_SIZE)
{
// read it
Serial.readBytes(incomingdata,COMMAND_SIZE);

boolean foundCommand = false; // true => got valid command

// while more commands
for(int cmdIdx=0; !foundCommand && cmdIdx < NUM_COMMANDS; cmdIdx++)
{
// compare incoming to valid command
int idx=0;
for( ; idx < COMMAND_SIZE; idx++)
if( commands[cmdIdx][idx] != incomingdata[idx] )
break;

// if we got a match
if( idx == COMMAND_SIZE )
{
// send appropriate character
Serial.print(sendStr[cmdIdx]);

// signal done
foundCommand = true;

} // if

} // for

} // if
}

Thank you in advance.

You have not told us what the data is being sent to?

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.

The technique in the 3rd example will be the most reliable. It is what I use for Arduino to Arduino and Arduino to PC communication.

You can send data in a compatible format with code like this (or the equivalent in any other programming language)

Serial.print('<'); // start marker
Serial.print(value1);
Serial.print(','); // comma separator
Serial.print(value2);
Serial.println('>'); // end marker

There is no need to create a single cstring before sending the data. As far as the receiving device is concerned these two versions will appear identical

Serial.println("Hello world");
Serial.print("Hello ");
Serial.println("world");

…R

Im receiving data from docklight in the form of at commands (STX 01 ETX) and in the reply im sending a string of data (02 00 30 12 32 03).
so there is a way if i can send all these commands in the form of string.
there are 3 more at commands .

nabeel_qureshi:
Im receiving data from docklight ....

What is "docklight"?

Have you carefully studied the examples in the link I gave you in Reply #1? I suspect not, as you replied about half an hour after I posted Reply #1.

...R