From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
03-17-2015 02:37 PM - edited 03-17-2015 02:45 PM
I have a system that receives data using GSM. It's a data from solid waste management system's Garbage Bin that informs when it has been emptied.
Below is the data received for when the bin gets full and for when the bin gets emptied.
\r\n+CMTI:\s"SM",1\r\nInCommingMassage[0]\s=\sCInCommingMassage[1]\s=\sMInCommingMassage[2]\s=\sTInCommingMassage[3]\s=\sIInCommingMassage[4]\s=\s:InCommingMassage[5]\s=\s\sInCommingMassage[6]\s=\s"InCommingMassage[7]\s=\sSInCommingMassage[8]\s=\sMInCommingMassage[9]\s=\s"InCommingMassage[10]\s=\s,InCommingMassage[11]\s=\s1AT+CMGR=1\r\r\n+CMGR:\s"REC\sUNREAD","+918460676836",,"15/03/18,00:49:52+22"\r\n*#Sb@!\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\r\n\r\nOK\r\nNumber\s=\sGR:\s"REC\sU*#Sb@!\s\s\s\s\s\s\s\s\s\sMassage\s=\s*#Sb@!\s\s\s\s\s\s\s\s\s\sAT\r\r\nOK\r\nAT\r\r\nOK\r\nAT+CMGF=1\r\r\nOK\r\nAT+CSCS="GSM"\r\r\nOK\r\nAT+CMGS="8866774133"\r\r\n>\sDustbin\sNo\s251\sFull,\sKindly\scollect\sthe\sgarbage\r\n+CMGS:\s46\r\n\r\nOK\r\nInCommingMassage[0]\s=\sCInCommingMassage[1]\s=\sMInCommingMassage[2]\s=\sGInCommingMassage[3]\s=\sSInCommingMassage[4]\s=\s:InCommingMassage[5]\s=\s\sInCommingMassage[6]\s=\s4InCommingMassage[7]\s=\s6InCommingMassage[8]\s=\s\rInCommingMassage[9]\r\nERROR\r\n\s=\s\nInCommingMassage[10]\s=\s\rInCommingMassage[\r\nERROR\r\n11]\s=\s\n\r\n+CMTI:\s"SM",2\r\nInCommingMassage[0]\s=\sCInCommingMassage[1]\s=\sMInCommingMassage[2]\s=\sTInCommingMassage[3]\s=\sIInCommingMassage[4]\s=\s:InCommingMassage[5]\s=\s\sInCommingMassage[6]\s=\s"InCommingMassage[7]\s=\sSInCommingMassage[8]\s=\sMInCommingMassage[9]\s=\s"InCommingMassage[10]\s=\s,InCommingMassage[11]\s=\s2AT+CMGR=2\r\r\n+CMGR:\s"REC\sUNREAD","+918460676836",,"15/03/18,00:50:33+22"\r\n!$@1400712094D1b\s\s\s\s\s\s\s\s\s\s\r\n\r\nOK\r\nNumber\s=\sGR:\s"REC\sU!$@1400712094D1bMassage\s=\s!$@1400712094D1b\02b\03\t\04GJ06\s3333\05\t\060:50:21\s18-3-15\07
From the above data, I want to extract the underlined data. The data between \02 and \03 in the first column, that between \04 and \05 in the second column, and that between \06 and \07 in the third column of an excel file. The system receives data whenever there's "empty" and "full" activity at the garbage bin. The following data that follows the previous one should be written into a different row.
I've attached the VI I'm using to read the Serial RS232 data.
03-17-2015 02:53 PM
Hi maulin
Use "match pattern" with "regular expression" equal to "\02" to find the begining of the requierd string then again use it for "\03" to find data between "\02" and "\03" and so on...
Kudos are appreciated
Regards
V.S
03-17-2015 03:57 PM - edited 03-17-2015 03:58 PM
03-18-2015 01:06 PM
Thank you V.V. and Ben64! It worked. But, it just detects once. Take for example, it has already read /02a/03/04GJDN1111/05/0612:00 18/03/2015/07
When the date changes to for eg: /02b/03/04GJDN1221/05/0613:00 18/03/2015/07 it doesn't show. Also It's not writing to a .csv file. I first converted it to an 1D array then gave the i/p to Write to Spreadsheet.
03-18-2015 01:21 PM
03-18-2015 02:40 PM
I did try that. I even tried giving a feedback loop from past offset to offset, but it just began blinking all the values. Also,why isn't it writing to a CSV file? I coonnected it the same way as you've. The spreadsheet stays blank.
03-18-2015 03:33 PM
03-19-2015 12:55 PM
Almost done! Now it's writing to the spreadsheet continuously rather than writing the data just once.
03-19-2015 01:30 PM
@maulin wrote:
Almost done! Now it's writing to the spreadsheet continuously rather than writing the data just once.
So your initial question is solved.
It is writing continuously because of this:
Even if a new read return an empty string you concatenate it with the the previous one. It is not the terminal content that you should pass to the while loop but only wire the string from frame 1. Also put the loop in a case structure an execute it only if the string is non-empty.
Ben64
03-19-2015 01:55 PM - edited 03-19-2015 01:57 PM
Yep. Initial query got solved. Thank you. But didn't know that I was going to encounter this new thing. Actually, I'm confused. I found this hyper terminal emulator online. I modified it according to my needs, but, now I don't know where it's receiving the first frame.