.net - C# SerialPort DSR/DTR and CTS/RTS handshaking -
i trying communicate device using c#/.net's serialport
class.
the documentation interacting device described here.
i using null modem cable tx/rx , handshake pins swapped (verified).
i expect following c# code work, not getting response (low high) camera trying interact with. sure problem code though. camera works other "pcs". why never dsrholding
(null modem cable, dtr high camera) become true within code?
static void main(string[] args) { var serialport = new serialport("com5"); // start dsr/dtr handshake // using null modem cable, dtr/dsr switched serialport.dtrenable = true; while (!serialport.dsrholding) { // probally should timeout instead of infinite wait thread.sleep(10); console.writeline("waiting dtr line go high."); } // start rts/cts handshake // using null modem cable, rts/cts switched serialport.rtsenable = true; while (!serialport.ctsholding) { // probally should timeout instead of infinite wait thread.sleep(10); console.writeline("waiting rts line go high."); } // read/write //serialport.write("some command"); //var response = serialport.readchar(); //while (response != stopbit) // response = serialport.readchar(); // close connection because have written/read our data // start dsr/dtr handshake // using null modem cable, dtr/dsr switched serialport.dtrenable = false; while (serialport.dsrholding) { // probally should timeout instead of infinite wait thread.sleep(10); console.writeline("waiting dtr line go low."); } // start rts/cts handshake // using null modem cable, rts/cts switched serialport.rtsenable = false; while (serialport.ctsholding) { // probally should timeout instead of infinite wait thread.sleep(10); console.writeline("waiting rts line go low."); } }
have tried using straight through cable? camera may take care of pins need crossed.
Comments
Post a Comment