Board index » cppbuilder » Problem with printing text using RS232

Problem with printing text using RS232


2005-02-26 05:12:17 AM
cppbuilder67
Can anyone help me with this:
I purchased an order printer (Epson TM200) with the following specifications:
Baud Rate 19200 bps
Data Bits 8 Bits
Handshaking Hardware
Parity Check Disabled,
More specifications can be found on: www.star-micronics.co.jp/eng/service/usermanual/tsp600sm.pdf
I downloaded a class that handel the serial communications from:
www.ciemmesoft.com/componenti/ and I wrote this code:
TCommPort *port = new TCommPort();
AnsiString com = Edit6->Text;
port->SetCommPort("COM1");
port->OpenCommPort();
port->SetBaudRate(19200);
port->SetParity(2);
port->SetStopBits(2);
port->SetByteSize(8);
String message = "Print this";
char *ch = message.c_str();
port->WriteString(ch);
port->CloseCommPort();
delete port;
When I execute the code I don't get anything on paper. But when I change the String message to message = "Print this message \n"; I get some other funny characters printed on the paper (not Print this)
Can anyone see what I am doing wrong?
The paper is almost finished because I am trying from this morning.
Thanks
 
 

Re:Problem with printing text using RS232

"Jan" < XXXX@XXXXX.COM >wrote in message
Quote
I downloaded a class that handel the serial communications from:
www.ciemmesoft.com/componenti/
That download link points to BCBDev, which no longer exists.
Quote
port->SetParity(2);
You said that the printer expects no Parity checking, but you are assigning
Even Parity instead. You will have to call its SetCommDCBProperties()
method to set up the parity checking manually.
Also, you did not set any Handshaking options at all. TCommPort does not
natively support setting up the handshaking, so you will have to call its
SetCommDCBProperties() method to set up the handshaking manually.
Quote
port->WriteString(ch);
You did not inform the serial port that data was available for sending. I
do not think TCommPort suppors this at all.
Also, WriteString() just dumps the string to the serial port and does not
wait to see if the string is actually transmitted. You can use
WriteStringSlow() to ensure each character is actually transmitted.
Gambit
 

Re:Problem with printing text using RS232

Jan wrote:
Quote
TCommPort *port = new TCommPort();
AnsiString com = Edit6->Text;
port->SetCommPort("COM1");
port->OpenCommPort();
port->SetBaudRate(19200);
port->SetParity(2);
port->SetStopBits(2);
port->SetByteSize(8);
In addition to what Remy mentioned.
Stops bits have almost always been 1 for about 25 years now.
Quote
I purchased an order printer (Epson TM200) with the following specifications:
Baud Rate 19200 bps
Data Bits 8 Bits
Handshaking Hardware
Parity Check Disabled,
More specifications can be found on: www.star-micronics.co.jp/eng/service/usermanual/tsp600sm.pdf
Did you check the dip-switch settings on the printer?
Section 12.3.1 of that manual says:
The baud rate may be 4800, 9600 or 19,200.
The parity may be even or odd or none
The stop bit is 1 (fixed)
The handshaking can be just about anything.
Double check your DIP Switch settings.
Put a break-out-box in the line, and check for proper DTS/DSR/RTS/CTS
functioning. I have yet to find a printer that handles those in the
manner that Microsoft dictates. (That is to say, the printers handle
them properly, but MS doesn't) I always have to cross signals, and
short some to get a printer working serially with hardware
handshaking.
 

{smallsort}