Breaking down a Serial data stream


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Breaking down a Serial data stream
# 1  
Old 02-04-2009
Data Breaking down a Serial data stream

I'm running Debian ib Bash shell. currently I'm streaming the data from ttyS1 . The data stream is 13 fields comma delimited

cat /dev/ttyS1

02/04/2009,10:57:18,1401.0,7.5,424.9,0.0,0.0,159.8,1401.0,7.5,265.2,34.4,2.5

The data is grouped for specific systems.

02/04/2009,10:57:18 date time
1401.0,7.5,424.9, "power company" current power , Daily power, Monthly
0.0,0.0,159.8, "Solar /Wind power" Current , Daily , Monthly
1401.0,7.5,265.2, "Differences" Current, Today, Month
34.4,2.5 Temperature outside, Wind Speed

I trying to pull these figures out and let me use them to create a web page to publish the data.

I'm using a bash. Any thoughts on how to proceed here.

Thank you

Michael
# 2  
Old 02-04-2009
Using awk - assume data in file called data

Quote:
awk '
BEGIN { FS=","
print "<html><body><table border=1><tr>"
print "<th>Date</th><th>Time</th>"
print "<th>Power Company - Current</th><th>Daily Power</th><th>Monthly</th>"
print "<th>Solar /Wind power - Current</th><th>Daily</th><th>Monthly</th>"
print "<th>Differences - Current</th><th>Today</th><th>Month</th>"
print "<th>Temperature outside</th><th>Wind Speed</th></tr>"
}
{
print "<tr>"
for (i = 1; i <= NF; i++ ) print "<td>"$i"</td>"
print "</tr>"
}
END { print "</table></body></html>"
} ' data > data.html
This gives output html file:

<html><body><table border=1><tr>
<th>Date</th><th>Time</th>
<th>Power Company - Current</th><th>Daily Power</th><th>Monthly</th>
<th>Solar /Wind power - Current</th><th>Daily</th><th>Monthly</th>
<th>Differences - Current</th><th>Today</th><th>Month</th>
<th>Temperature outside</th><th>Wind Speed</th></tr>
<tr>
<td>02/04/2009</td>
<td>10:57:18</td>
<td>1401.0</td>
<td>7.5</td>
<td>424.9</td>
<td>0.0</td>
<td>0.0</td>
<td>159.8</td>
<td>1401.0</td>
<td>7.5</td>
<td>265.2</td>
<td>34.4</td>
<td>2.5</td>
</tr>
<tr>
</tr>
</table></body></html>
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Debian

Reading data from a serial port

Dear List - I am trying to capture data from a serial port and write it to a file. /var/www$ cat /dev/ttyS0 > scale_value.html cat: /dev/ttyS0: Device or resource busy /var/www# cat /proc/tty/driver/serial serinfo:1.0 driver revision: 0: uart:16550A port:000003F8 irq:4 tx:90... (11 Replies)
Discussion started by: Meow613
11 Replies

2. Shell Programming and Scripting

Extract & Manipulate continous data stream-- tcpdump

Hello; I have this rather tricky problem to solve --(to me, anyways) .. I am processing the following one liner with tcpdump.. tcpdump -i T3501 -A ether host 00:1e:49:29:fc:c9 or ether host 00:1b:2b:86:ec:1b or ether host 00:21:1c:98:a4:08 and net 149.83.6.0/24 | grep --line-buffered -B... (5 Replies)
Discussion started by: delphys
5 Replies

3. Programming

Wrong data with Read from a serial port.

hi, I've a problem on my C/C++ program with Posix Library. I have to read data from the serial but I have incorrect data, in fact I get a bunch of zeros: "2953.3174, 2785.2126, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0 , 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ,... (24 Replies)
Discussion started by: enaud
24 Replies

4. UNIX for Dummies Questions & Answers

Read data from given filename or stream

I have a script that takes 2 parameters (say) as mandatory script1.sh a b The 3rd parameter can be filename which it should process or it can come through a pipeline stream The script should work both ways: script1.sh a b filec or cat filec | script1.sh a b How to put logic in the... (1 Reply)
Discussion started by: ysrini
1 Replies

5. Shell Programming and Scripting

Data stream between min and max

Hi, I have a text file containing numbers. There are up to 6 numbers per row and I need to read them, check if they are 0 and if they are not zero check if they are within a given interval (min,max). If they exceed the max or min they should be set to max or min respectively, if they are in the... (4 Replies)
Discussion started by: f_o_555
4 Replies

6. Shell Programming and Scripting

[Video stream] network stream recording with mplayer

Hi I used this command: mplayer http://host/axis-cgi/mjpg/video.cgi -user root -passwd root \ -cache 1024 -fps 25.0 -nosound -vc ffh264 \ -demuxer 3 -dumpstream -dumpfile output.avi It's ok but... Video Playing is very fast! Why? Is it a synch problem? What parameter I have to use for... (1 Reply)
Discussion started by: takeo.kikuta
1 Replies

7. Programming

Problem with read data from serial device

I have problem with C programming. I want to send & receive data through serial communication. I send data(command) to device to get data from device but when receive data, it can't get altogether of data. It get only some data. What should I do to get altogether of data? If all of... (7 Replies)
Discussion started by: noppon_s
7 Replies

8. SCO

data transfer from serial port

dear sir, pls. can you help me ? , my os is unix sco 5.0.4 and ,server dat derive (1,4gb) not working, now i want to transfer my server data in other machine (unix/other possible) by serial port/other port comminication. thanks pankaj raval (2 Replies)
Discussion started by: pankajbraval
2 Replies

9. Programming

Reading incoming data in serial ports

Hi every body, i have the following problem : I need to read incoming data from a serial port, this port has connected a weigth device to it that send the weigth and i need to read this data to my aplication, i had this problem in Window Enviroment and i resolve with a "C" routine, but in Unix... (1 Reply)
Discussion started by: jricardorm
1 Replies
Login or Register to Ask a Question