Click here to Skip to main content
15,879,348 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi all,

i try to connect pc to laboratory device. i can get message from the device. but the problem is splitting the results.

here is the text i received from the device
C#
<STX>1H|\^&|||H7600^1|||||host|RSUPL^BATCH|P|1<CR>P|1|||||||U||||||^<CR>O|1|            mithat|0^50010^010^^S1^SC|^^^687^\^^^685^\^^^418^\^^^717^\^^^19^\^^^698^\^^^700^\^^^690^|R||||||N||||1|||||||20160430020618|||F<CR>C|1|I|                          <ETB>BE<CR><LF><STX>2    ^                         ^                    ^               ^          |G<CR>R|1|^^^687/|12.5|U/l||N||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|2|^^^685/|12.7|U/l||N||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|3|^^^418/|35.1|mg/dl||N||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|4|^^^<ETB>4D<CR><LF><STX>3717/|101.5|mg/dl||N||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|5|^^^19/|0.186|mg/dl||N||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|6|^^^698/|10.48|mg/dl||H||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|7|^^^700/|4.0|mg/dl||N||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|8|^^^690/|0.67|mg/dl||L||F||bmserv||<ETB>C1<CR><LF><STX>4|P1<CR>C|1|I|0|I<CR>L|1|N<CR><ETX>44<CR><LF><EOT>


I want to get the name ( or ID) which is mitat and results begin from
C#
<CR>R|1|^^^687/|12.5|U/l||N||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|2|^^^685/|12.7|U/l||N||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|3|^^^418/|35.1|mg/dl||N||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|4|^^^<ETB>4D<CR><LF><STX>3717/|101.5|mg/dl||N||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|5|^^^19/|0.186|mg/dl||N||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|6|^^^698/|10.48|mg/dl||H||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|7|^^^700/|4.0|mg/dl||N||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|8|^^^690/|0.67|mg/dl||L||F||bmserv||<ETB>C1<CR>



how can i get this?

Thank you.

What I have tried:

C#
private void button1_Click(object sender, EventArgs e)
        {
            string[] gelen = tbMetin.Text.Split('|');
            string[] bolmeKriteri = new string[] { "\\r" };
            string[] sonuclar;
            string[] kalanlar;
            if (gelen.Length > 11)
            {
                if(gelen[10]== "RSUPL^REAL")
                {
                    listBox.Items.Add("Tek Sonuç Geldi");
                    for(int i=11;i<gelen.length;i++)>
                    {
                        sonuclar = gelen[i].Split(bolmeKriteri, StringSplitOptions.None);
                        for (int j=0;j<sonuclar.length;j++)>
                        {
                            listBox.Items.Add(sonuclar[j]);
                        }
                    }
                }else if(gelen[10]== "RSUPL^BATCH")
                {
                    listBox.Items.Add("Toplu Sonuç Geldi.");
                    for (int i = 11; i < gelen.Length; i++)
                    {
                        sonuclar = gelen[i].Split(bolmeKriteri, StringSplitOptions.None);
                        for (int j = 0; j < sonuclar.Length; j++)
                        {
                            listBox.Items.Add(sonuclar[j]);
                        }
                    }
                }
            }
        }
Posted
Updated 1-May-16 9:43am
v2
Comments
Sergey Alexandrovich Kryukov 1-May-16 15:22pm    
The question makes little sense. Even if you really receive messy text response from the device (those people developing firmware and software for industrial or laboratory hardware tend to do really bad job; this is just the fact of nature), you have to sort it out, read the documentation of the vendor, experiment with it, and so on. But you expect strangers to sort it out for you, without giving any relevant information. Just a sample or two is not the definition of data structure and semantics, it's nothing.
—SA
George Jonsson 1-May-16 19:22pm    
Do you have any documentation of the protocol?

1 solution

My guess is that what you show is not what you received and that it is preprocessed to show non printable chars.
<cr> being the Carriage Return.
<stx>1H|\^&|||H7600^1|||||host|RSUPL^BATCH|P|1<cr>
P|1|||||||U||||||^<cr>
O|1|            mithat|0^50010^010^^S1^SC|^^^687^\^^^685^\^^^418^\^^^717^\^^^19^\^^^698^\^^^700^\^^^690^|R||||||N||||1|||||||20160430020618|||F<cr>
C|1|I|                          <etb>BE<cr><lf><stx>2    ^                         ^                    ^               ^          |G<cr>
R|1|^^^687/|12.5|U/l||N||F||bmserv|||P1<cr>
C|1|I|0|I<cr>
R|2|^^^685/|12.7|U/l||N||F||bmserv|||P1<cr>
C|1|I|0|I<cr>
R|3|^^^418/|35.1|mg/dl||N||F||bmserv|||P1<cr>
C|1|I|0|I<cr>
R|4|^^^<etb>4D<cr>
<lf><stx>3717/|101.5|mg/dl||N||F||bmserv|||P1<cr>
C|1|I|0|I<cr>
R|5|^^^19/|0.186|mg/dl||N||F||bmserv|||P1<cr>
C|1|I|0|I<cr>
R|6|^^^698/|10.48|mg/dl||H||F||bmserv|||P1<cr>
C|1|I|0|I<cr>
R|7|^^^700/|4.0|mg/dl||N||F||bmserv|||P1<cr>
C|1|I|0|I<cr>
R|8|^^^690/|0.67|mg/dl||L||F||bmserv||<etb>
C1<cr><lf>
<stx>4|P1<cr>
C|1|I|0|I<cr>
L|1|N<cr>
<etx>44<cr><lf>
<eot>


You have to check how you receive the data, and certainly have to read the documentation.
 
Share this answer
 
v3
Comments
Halit YILMAZ 1-May-16 17:22pm    
\u00021H|\\^&|||H7600^1|||||host|RSUPL^REAL|P|1\rP|1|||||||U||||||^\rO|1| colin james taylor|0^50011^011^^S1^SC|^^^435^\\^^^687^\\^^^685^\\^^^418^\\^^^59^\\^^^798^\\^^^717^\\^^^19^\\^^^690^\\^^^781^|R||||||N||||1|||||||20160427184217|||F\rC|1|I| \u001783\r\n\u0004

This is a part of code that I received from serial port. I don't know how to split <cr> and get patient data and test results with test codes.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900