help with CSerial (code included)
-
i'm trying to communicate with a relay box connected with a serial cable. you send a command of N1 to open the first relay, N2 to open the second, etc... i've tested it with hyperterminal and it works fine. i'm usin a c++ mfc app in vs.net03. i've just added code to my program, if there are any settings that i have to set, then i don't know about them. i'm using the CSerial class http://www.codeproject.com/system/serial.asp portName and relay are both CStrings. anyone know what's wrong?? CSerial link; link.Open(portName); //either COM1 or COM2 //set the port settings link.Setup(CSerial::EBaudrate(9600), CSerial::EDataBits(, CSerial::EParity(NOPARITY), CSerial::EStopBits(ONESTOPBIT)); if(relay[0]=='1') relay.Delete(0,1); link.Write(relay); //writing "N1" or whatever //find time for pump to stay open runtime=drinklist[num].amount[x]*MULTIPLIER; Sleep(runtime*1000); relay.Delete(0,1); relay.Insert(0,"F"); link.Write(relay); link.Close(); thanx
-
i'm trying to communicate with a relay box connected with a serial cable. you send a command of N1 to open the first relay, N2 to open the second, etc... i've tested it with hyperterminal and it works fine. i'm usin a c++ mfc app in vs.net03. i've just added code to my program, if there are any settings that i have to set, then i don't know about them. i'm using the CSerial class http://www.codeproject.com/system/serial.asp portName and relay are both CStrings. anyone know what's wrong?? CSerial link; link.Open(portName); //either COM1 or COM2 //set the port settings link.Setup(CSerial::EBaudrate(9600), CSerial::EDataBits(, CSerial::EParity(NOPARITY), CSerial::EStopBits(ONESTOPBIT)); if(relay[0]=='1') relay.Delete(0,1); link.Write(relay); //writing "N1" or whatever //find time for pump to stay open runtime=drinklist[num].amount[x]*MULTIPLIER; Sleep(runtime*1000); relay.Delete(0,1); relay.Insert(0,"F"); link.Write(relay); link.Close(); thanx
From you example: link.Setup(CSerial::EBaudrate(9600), CSerial::EDataBits(, CSerial::EParity(NOPARITY), CSerial::EStopBits(ONESTOPBIT)); From http://www.codeproject.com/system/serial.asp: serial.Setup(CSerial::EBaud9600,CSerial::EData8,CSerial::EParNone,CSerial::EStop1); Just a thought! INTP
-
From you example: link.Setup(CSerial::EBaudrate(9600), CSerial::EDataBits(, CSerial::EParity(NOPARITY), CSerial::EStopBits(ONESTOPBIT)); From http://www.codeproject.com/system/serial.asp: serial.Setup(CSerial::EBaud9600,CSerial::EData8,CSerial::EParNone,CSerial::EStop1); Just a thought! INTP
-
those two lines are the same, or so the example says. any other suggestions. i'm really stuck here
When working on serial communication I have found it usful to run a terminal program on another machine and capture the data output from my program. If it receives garbage, then it is a port setup problem (or bad serial port). If it receive nothing, then either I selected the wrong output port or (heaven forbid) I forgot to make sure the port open successfuly. I hope this will at least help a little, since I have not used CSerial. I tend to write my own using file I/O (on Win32 platforms). INTP
-
When working on serial communication I have found it usful to run a terminal program on another machine and capture the data output from my program. If it receives garbage, then it is a port setup problem (or bad serial port). If it receive nothing, then either I selected the wrong output port or (heaven forbid) I forgot to make sure the port open successfuly. I hope this will at least help a little, since I have not used CSerial. I tend to write my own using file I/O (on Win32 platforms). INTP
Hi, Could you please let me know how you can runa terminal program to capture the output from another program?I am in the process of developing a serial communication between a laptop and PDA.I have to send data from the lpatop which has to be read by the PDA. Thanking you for your time, Deepa. John R. Shaw wrote: When working on serial communication I have found it usful to run a terminal program on another machine and capture the data output from my program. If it receives garbage, then it is a port setup problem (or bad serial port). If it receive nothing, then either I selected the wrong output port or (heaven forbid) I forgot to make sure the port open successfuly. I hope this will at least help a little, since I have not used CSerial. I tend to write my own using file I/O (on Win32 platforms). INTP
-
Hi, Could you please let me know how you can runa terminal program to capture the output from another program?I am in the process of developing a serial communication between a laptop and PDA.I have to send data from the lpatop which has to be read by the PDA. Thanking you for your time, Deepa. John R. Shaw wrote: When working on serial communication I have found it usful to run a terminal program on another machine and capture the data output from my program. If it receives garbage, then it is a port setup problem (or bad serial port). If it receive nothing, then either I selected the wrong output port or (heaven forbid) I forgot to make sure the port open successfuly. I hope this will at least help a little, since I have not used CSerial. I tend to write my own using file I/O (on Win32 platforms). INTP
I have not used CSerial either. In order to use a terminal program, such as hyper-terminal (comes with all PC versions of windows), you will need to make null-modem cable or you may buy one at a computer supply store like radio shack. The wiring for a null-modem cable can be found on the net or in a book on serial communications. If you are doing your serial communication using a USB port, you may also need a USB to 9-pin serial cable or 2. When you setup the teminal side, you need to make sure that it is not doing something funky with that data (like replacing CR with CR/LF). The data must be saved without modification (received as binary not text). Once you have set the serial-port properties, then all you need to do is select receive file. The terminal program will sit there and wait until data starts arriving at the port, at which time it will start coping the data to the given file (for later analisys). Well, I hope this helps you! Good Luck! INTP