简体   繁体   中英

How to open cash box more than once in a little time?

This code runs successfully,

Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.Start();

p.StandardInput.WriteLine(@"dir >com1");

But if I try to run the same code again before ~30 seconds it does not work. If I wait ~30 seconds and try to run again it works with no problem.

What can I do to open Cash Box more than once in short succession?

I tried your code with one little tweak: I redirected the output of the dir command to a file and it worked.

p.StandardInput.WriteLine(@"dir > C:\text" + (ID++)  + ".txt");

My guess is that you might want to look for the COM port (timeout issues?) or look for an alternative, like printing the output of the command in files and have one another process readings the files and sending the content of those files one after another on the serial port.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM