Welcome to Dream.In.Code
Become a C++ Expert!

Join 149,501 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,377 people online right now. Registration is fast and FREE... Join Now!




Collecting and parsing data from a com port

 
Reply to this topicStart new topic

Collecting and parsing data from a com port, writing data to a file and chanding hex to dec for graphic representat

DawgPound
22 Mar, 2007 - 05:23 AM
Post #1

New D.I.C Head
*

Joined: 22 Mar, 2007
Posts: 2


My Contributions
Hi,

My problem that I am having is that I am using wireless sensors to collect and transmit data samples to my computer and I need to manipulate the packet data into graphically representable data. The packets of data that reach my computer are in hex. I can use a terminal program to show me and log the data coming to my computer, which logs it like so:

Terminal log file
Date: 2/21/2007 - 9:47:40 AM
-----------------------------------------------
7E 42 FF FF 00 7D 5D 26 84 01 01 00 C5 00 1E 03
C5 00 1E 03 C4 00 1E 03 C4 00 1E 03 C5 00 1F 03
C5 00 1E 03 C5 00 1F 03 C5 00 1F 03 C5 00 69 D1
7E 7E 42 FF FF 00 7D 5D 26 84 01 01 00 C5 00 1E
03 C5 00 1F 03 C5 00 1F 03 C5 00 1F 03 C5 00 1E
03 C5 00 1F 03 C5 00 1F 03 C4 00 1F 03 C5 00 05
D8 7E 7E 42 FF FF 00 7D 5D 26 84 01 01 00 C5 00
1E 03 C5 00 1E 03 C5 00 1F 03 C5 00 1F 03 C4 00
1F 03 C4 00 1F 03 C5 00 1F 03 C4 00 1E 03 C5 00
51 A9 7E 7E 42 FF FF 00 7D 5D 26 84 01 01 00 C5
00 1F 03 C5 00 1E 03 C4 00 1E 03 C4 00 1E 03 C5
00 1E 03 C4 00 1E 03 C5 00 1F 03 C4 00 1E 03 C5
00 7D 5E 68 7E 7E 42 FF FF 00 7D 5D 26 84 01 01
00 C5 00 1E 03 C5 00 1F 03 C4 00 1F 03 C5 00 1F
03 C5 00 1F 03 C4 00 1F 03 C5 00 1F 03 C5 00 1F
03 C5 00 81 E2 7E 7E 42 FF FF 00 7D 5D 26 84 01
01 00 C5 00 1E 03 C5 00 1E 03 C5 00 1E 03 C5 00
1E 03 C5 00 1E 03 C5 00 1E 03 C5 00 1E 03 C5 00
1E 03 C5 00 93 89 7E
-----------------------------------------------
Date: 2/21/2007 - 9:47:46 AM
End log file

now one packet of information consits of 7E to 7E such as the first packet shown is:

7E 42 FF FF 00 7D 5D 26 84 01 01 00 C5 00 1E 03 C5 00 1E 03 C4 00 1E 03 C4 00 1E 03 C5 00 1F 03 C5 00 1E 03 C5 00 1F 03 C5 00 1F 03 C5 00 69 D1 7E

Of this packet the data that I need to convert and save is from:

01 00 C5 00 1E 03 C5 00 1E 03 C4 00 1E 03 C4 00 1E 03 C5 00 1F 03 C5 00 1E 03 C5 00 1F 03 C5 00 1F 03 C5 00

I also need to know the byte:

01 ....which will either be a 01 or 02 depending upon which sensor this data is coming from.

The packet data that I need to convert is in Little Indian format with two bytes per sample and 17 samples per packet.

Can sombody please show me how to collect the packets coming in through a serial cable, divide the incoming packets into seperate files for each sensor and then how to turn the 18 samples per packet into a decimal number for graphic representation? Any help is much appreciated.

Thanks
User is offlineProfile CardPM
+Quote Post

horace
RE: Collecting And Parsing Data From A Com Port
22 Mar, 2007 - 05:55 AM
Post #2

D.I.C Addict
Group Icon

Joined: 25 Oct, 2006
Posts: 573



Thanked: 5 times
Dream Kudos: 50
My Contributions
what compiler/operating system are you using?


User is offlineProfile CardPM
+Quote Post

DawgPound
RE: Collecting And Parsing Data From A Com Port
22 Mar, 2007 - 05:59 AM
Post #3

New D.I.C Head
*

Joined: 22 Mar, 2007
Posts: 2


My Contributions
QUOTE(horace @ 22 Mar, 2007 - 06:55 AM) *

what compiler/operating system are you using?


I am trying to use LabWindows on a windows machine to do this.
User is offlineProfile CardPM
+Quote Post

horace
RE: Collecting And Parsing Data From A Com Port
22 Mar, 2007 - 08:48 AM
Post #4

D.I.C Addict
Group Icon

Joined: 25 Oct, 2006
Posts: 573



Thanked: 5 times
Dream Kudos: 50
My Contributions
QUOTE(DawgPound @ 22 Mar, 2007 - 01:59 PM) *

QUOTE(horace @ 22 Mar, 2007 - 06:55 AM) *

what compiler/operating system are you using?


I am trying to use LabWindows on a windows machine to do this.

I have never used LabWindows but doing a quick web search turned up many links to pages discussing the topic. I suggest you have a look thru the LabWindows manual and see if there are exmples of using serial ports to acquire data.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/7/09 06:38PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month