Reading serial strings and calling multiple functions.

Hi - I'm new to programming and I'm struggling with serial inputs.

For example, using the sample code provided by Robin2, I can obviously write and print arrays all day long however, inut a string such as:

"Some text here for a particular function "

How might I go about reading the serial info, separating the regular text at the start from the data for the array, and then calling the two seperate funtions as a result?

Note: I need to be able to deal with all three of the following string examples:

"Some Data"
"Some Data"
""

So the system nees to make a call on whether its seeing some data that I reference in one function, the data for the array, or both.

TIA

You are asking how to manipulate strings in C. Here is a good reference:

C String Functions

Most of what you are asking is in the Arduino Cookbook and if I remember correctly so are some examples.

My SafeString library provides a rich set of safe string manipulation functions.
The SafeStringReader provides a way to read and tokenize the input based on specified delimiters
but it looks like you need a state machine to keep track of where you are in the parsing when you split the input across two lines.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.