Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch-File: Receive Data from the Serial-Port and write it into txt-File

I'm trying to extract some data from an Arduino over the usb-serial-port and to write it into a txt-file. Therefore i'm using a batch-file (Windows 7, ordinary cmd), which sends e.g. a "d" to request the desired data from the Arduino. Having received the "d", the Arduino starts to send the data to the pc. The batch-file reads the data and writes it to some txt-file. The batch code is:

    mode COM4 BAUD=9600 PARITY=n DATA=8
    echo d >COM4
    COPY COM4 data.txt

That works so far, but the problem is:

How do I stop the COPY-process?

When the Arduino is done with sending the data, the batch file keeps on wating for more. My preferred solution would be, that the Arduino sends some string like "end", the batch file recognizes this and stops reading. Is that somehow possible?

like image 430
DonCookie Avatar asked Oct 21 '13 08:10

DonCookie


1 Answers

I believe that copy will recognize a Control-Z as an end of file character and terminate.

Harkens way back to the old dos days, am I showing my age?

like image 135
Jeff Avatar answered Oct 01 '22 18:10

Jeff