Code: Select all
<MenTime>11/02/2014 23:05:20</MenTime><msg><src>CC128-0.11</src><dsb>01369</dsb><time>22:57:56</time><tmpr>19.7</tmpr><sensor>0</sensor><id>00077</id><type>1</type><ch1><watts>00485</watts></ch1></msg>
Using this command in batch Dos
I get this raw from serial port, each raw is push every 6 seconds from serial port:"Type COM3"
Code: Select all
<msg><src>CC128-0.11</src><dsb>01369</dsb><time>22:57:56</time><tmpr>19.7</tmpr><sensor>0</sensor><id>00077</id><type>1</type><ch1><watts>00485</watts></ch1></msg>
But this raw it's missing from this initial part:
Code: Select all
<MenTime>11/02/2014 23:05:20</MenTime>
So I create this Batch:
Code: Select all
@echo on
REM _________ D A T E A N D T I M E ___________________________________________
for /f "delims=" %%A in ('wmic OS Get localdatetime ^| find "."') do set DATETIMEWMI=%%A
set Y=%DATETIMEWMI:~0,4%
set M=%DATETIMEWMI:~4,2%
set G=%DATETIMEWMI:~6,2%
set HH=%DATETIMEWMI:~8,2%
set MM=%DATETIMEWMI:~10,2%
set SS=%DATETIMEWMI:~12,2%
set MS=%DATETIMEWMI:~15,2%
set DD=%G%%M%%Y%
set DD0=%Y%-%M%-%G%
set DD1=%G%/%M%/%Y%
set ORA=%HH%%MM%
set ORA1=%HH%.%MM%.%SS%
set ORA2=%HH%:%MM%:%SS%
set TIMESTAMP=%G%%M%%Y%_%HH%%MM%%SS%
REM ______________________________________________________________________________________
SET Head=<MenTime>%DD1% %ORA2%</MenTime>
type nul > C:\Meniscus\Data\abcdefghi_%TIMESTAMP%
type COM3 >> C:\Meniscus\Data\abcdefghi_%TIMESTAMP%
First problem why doesn't work this set "SET Head"
Second problem, how can I quit "type COM3" after 20 raw
Third problem I call this script with another one to have different variable in MenTime, but command "type Com3" does't quit
This is a example of correct file "abcdefghi_%TIMESTAMP%"
<MenTime>11/02/2014 23:04:51</MenTime><msg><src>CC128-v0.11</src><dsb>01369</dsb><time>22:57:26</time><tmpr>19.6</tmpr><sensor>0</sensor><id>00077</id><type>1</type><ch1><watts>00477</watts></ch1></msg>
<MenTime>11/02/2014 23:04:57</MenTime><msg><src>CC128-v0.11</src><dsb>01369</dsb><time>22:57:32</time><tmpr>19.6</tmpr><sensor>0</sensor><id>00077</id><type>1</type><ch1><watts>00467</watts></ch1></msg>
<MenTime>11/02/2014 23:05:03</MenTime><msg><src>CC128-v0.11</src><dsb>01369</dsb><time>22:57:38</time><tmpr>19.6</tmpr><sensor>0</sensor><id>00077</id><type>1</type><ch1><watts>00473</watts></ch1></msg>
Thanks in advance and Regards