D
DaVinci
I did a google web & group search and didn't find an answer to my
question so... here we go. Will try to keep it short. (I am not a
complete beginner but am still pretty low on the food chain).
Two programs on two different machines. Program 1 is given values for
multiple variables. Program 1 then sends everything to Program 2 in an
ascii character format. Program 2 then needs to parse the input
buffer, extract the type of data and value, and set its own variables.
I need to keep speed in mind at all times because there will be large
amounts of data to process. I will also be dealing with the same
variables each cycle and I know all of them in advance. They could
change from time to time so I do not want to base the data on specific
locations in the buffer. Also, some may not be present on each cycle.
I could bring in a certain number of characters, say the first three
will specify what the data is, and use an if statement to see what it
is and then assign the numbers after it to a variable. However, this
seems really long and slow and they has got to be a better way.
Using either #define or an enum, I could specify in program 2 all the
data types that it may find in the string and when I send everything
from program 1, I can have it put a : between then so it will be
easier to parse.
Example: Sending VEL=500:TEL=400:SEL=300: into program 2.
Q1: I could setup something (enum, typedef, ??) to bind VEL to a
variable named Vello, TEL to tello, and SEL to sello. What is the best
way to do that for readability and speed?
Q2: Now that I have the specifiers in the buffer linked to a variable
in the program, what would be the fastest way to get the values into
the variables (match them up)? With the knowledge I have now I could
make a for loop with an if loop to check each part of the buffer as it
is read and compare the parts coming in with the pre-defined variables
and then store the variable (via pointer as it will not be local to
the function). But again, there has got to be a faster / better
method.
Thanks for any advice.
question so... here we go. Will try to keep it short. (I am not a
complete beginner but am still pretty low on the food chain).
Two programs on two different machines. Program 1 is given values for
multiple variables. Program 1 then sends everything to Program 2 in an
ascii character format. Program 2 then needs to parse the input
buffer, extract the type of data and value, and set its own variables.
I need to keep speed in mind at all times because there will be large
amounts of data to process. I will also be dealing with the same
variables each cycle and I know all of them in advance. They could
change from time to time so I do not want to base the data on specific
locations in the buffer. Also, some may not be present on each cycle.
I could bring in a certain number of characters, say the first three
will specify what the data is, and use an if statement to see what it
is and then assign the numbers after it to a variable. However, this
seems really long and slow and they has got to be a better way.
Using either #define or an enum, I could specify in program 2 all the
data types that it may find in the string and when I send everything
from program 1, I can have it put a : between then so it will be
easier to parse.
Example: Sending VEL=500:TEL=400:SEL=300: into program 2.
Q1: I could setup something (enum, typedef, ??) to bind VEL to a
variable named Vello, TEL to tello, and SEL to sello. What is the best
way to do that for readability and speed?
Q2: Now that I have the specifiers in the buffer linked to a variable
in the program, what would be the fastest way to get the values into
the variables (match them up)? With the knowledge I have now I could
make a for loop with an if loop to check each part of the buffer as it
is read and compare the parts coming in with the pre-defined variables
and then store the variable (via pointer as it will not be local to
the function). But again, there has got to be a faster / better
method.
Thanks for any advice.