Hello, I've read the other posts about using VBscripting to store serial data to a file. However, I'm having an issue adapting the VB code for my usage.
I run an arduino code that only print to the serial port periodically. When I run this code (see below. found here: Wise time with Arduino: Arduino writes to file ) the code automatically stops after some short time, (after a few seconds it's no longer listed in the task manager processes) and I have a feeling it's because I'm not continuously printing serial data. I suspect the issue might be with the "do while..." line in the VBscript, but I'm not sure.
any ideas? thanks!
dave
Const ForReading = 1
Const ForWriting = 2
Set fso = CreateObject("Scripting.FileSystemObject")
Set com = fso.OpenTextFile("COM6:9600,N,8,1", ForReading)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\results.txt", ForWriting, True)
MsgBox("Start to read data from COM")
Do While com.AtEndOfStream <> True
s = com.ReadLine
objFile.WriteLine(s)
WScript.Sleep(200)
Loop
objFile.Close
com.Close()