Hi
I need a pointer in the right direction.
I receive a string of data from hardware in the following format
" 01 1 2 1 0340 10 33 56 08 09 20 09 0002 0010 0000 0303 0303 0600 0000 0600 0000 0349 0302 0349 0301 0349 0303 0349 0203 0413 0500"
I need to put these values or words in an array with 5 elements. The non numerical char is a Ascii 4 to signal start of the string and the vertical lines is ascii 5 to signal a new element in the array. 4 elements will have a fixed lenght with the same amount of words everytime. the fourth element needs to be variable and receives two columns of words, each one is the temperature of a probe, problem is the recorder sometimes take temp reading for an hour and sometimes up to 5 hours at 5 second intervals. So this is why the fourth element must take a variable lenght.
these words need to be parsed into a float and used to draw a graph which should not be too difficult.
I just need help on how to get the string above into an 5 element array.
Any Ideas?
Recommended Answers
Jump to PostHi,
I would try to split it into groups with use of Regular expressions.
I did not really understand what should the goal array look like, maybe you could make an example with marking the variable parts and I could try to fiture out the RegExp for it.
Jump to PostWhat language is the original software written in?
Also take the buffer you receive and write it to a text file and upload it here.
Jump to PostI see the control characters near the header and then a lot of text afterwards.. I thought these control characters would repeat evenly through the buffer, or does that only signify the start of a transmission?
Also is this the byte[] array written to a file or did you …
Jump to PostLets call the string starting witt chr(004) and ending with Temperature probe serial number a message.
Are you able to wait till you get the whole message or you must generate the graph in realtime as the temp data flows as it can take long to complete?
Jump to PostHi, this does the job if you have int in a file...or somewhere else where you can read the message and process it then.
string input = ""; StreamReader sr = new StreamReader("c:/Vm_data/temp.txt"); while (sr.Peek() >= 0) { input += sr.ReadLine(); } string[] data = input.Split(Convert.ToChar(005));
You …
All 18 Replies
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.