Reading and parsing arduino data from the terminal


I am not sure how best to go about this.

Firstly the scenario is that I have my arduino sketch which is pumping out some data


Data: NULL Data: NULL Data: NULL Data: NULL Data: 24A7 Data: 85C1 Data: 3F57

What I want to do is read this data with my bash script and then when the data is !NULL I want to get the first Data value and reset the arduino. I want to repeat this test n times.

Obviously all I am interested in is the first 2 Byte value.

What I need to ensure is that When I reset that I don't read an old Data value and only get the first good data value.

The reason I want to do it in bash (I kind of assumed this would be the easiest way) is that I will want to run this test about 1000 times so doing it by hand would be a real pain in the ***.

I need to append the value to a file.

Many Thanks

I suggest you write a short Python program to do what you want. This demo may give you a start.