1 Replies - 5388 Views - Last Post: 11 March 2009 - 11:27 PM Rate Topic: -----

#1 Cerebro  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 11-March 09

How to send command to serial ports in C++

Post icon  Posted 11 March 2009 - 06:08 PM

Hi,

I'm really new to C++. I'd like to know how to send command to serial ports.
Im connecting to a uniwell POS machine and I dont know what commands I'll be using. They gave me this serial communication protocol manual with this format.


1.4 Clear All Request

It is always safest to clear all existing report requests before you request the days reports. This is done by sending the following request.

SOH C - A STX 0 1 CR LF ETX BCC


how do you send commands like that to a serial port? I know it would be using a WriteFile command but my concern is the format of the command that I'll be using.. coz I havent received any reply from the POS machine I'm trying to connect.

thank you.

Is This A Good Question/Topic? 0
  • +

Replies To: How to send command to serial ports in C++

#2 horace  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 290
  • View blog
  • Posts: 1,898
  • Joined: 25-October 06

Re: How to send command to serial ports in C++

Posted 11 March 2009 - 11:27 PM

have a look at
http://www.codersour...p_approach.aspx
http://www.codeproje...tem/serial.aspx
http://www.codeguru....ticle.php/c2503
http://www.codeguru....ticle.php/c2483

have you tried connecting to the POS machine using a terminal emulator program such as hyperterm. You need to set the PC baud raete, number of data bits, parity and number of stop bits to match the POS machine. If you don't know the baud rate try 9600 baud, 8 data bits, no parity one stop bit. If you see garbage on the screen the baud rate is probably wrong - try changing it until it works. If nothing appears on the screen the wiring could be wrong, e.g. do you need to connect the hardware handshaking lines?

for details of control characters such as SOH, STX ,etc see
http://www.asciitable.com/

This post has been edited by horace: 11 March 2009 - 11:29 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1