5 Replies - 1770 Views - Last Post: 20 July 2016 - 12:19 PM Rate Topic: -----

#1 ibnmvungi   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 93
  • Joined: 20-April 12

sending a packet to serial (RS232 Communication)

Posted 20 July 2016 - 11:01 AM

hallo! there, I am new to serial communication.

I found a serial class from microsoft that makes one be able to make a serial connection.

I have a POS device that need to be integrated.
The documentation says

Quote

Data transmission to and from the Terminal is Asynchronous at up to 115200 bps, with 8 data bits, no
parity, and 1 stop bit (11520,8,n,1).


I can make a connection to serial using like this

    // Create a new SerialPort object with default settings.
            comport = new SerialPort();
            if (comport.IsOpen) comport.Close();

            // Allow the user to set the appropriate properties.
            comport.PortName = "COM7";
            comport.BaudRate = 115200;
            comport.Parity = 0;
            comport.DataBits = 8;
            comport.Handshake = Handshake.None;
            comport.StopBits = (StopBits)Enum.Parse(typeof(StopBits), "1");   //StopBits
            comport.Parity = (Parity)Enum.Parse(typeof(Parity), "0");   //Parity

            // Set the read/write timeouts
            comport.ReadTimeout = 500;
            comport.WriteTimeout = 500;

            comport.DataReceived +=new SerialDataReceivedEventHandler(MyDataReceivedHandler);

            comport.Open();
          
            label1.Text = "Comport connected.";




As the document gives more details

[quote]Messages are communicated to and from the POS using the format as shown: (image attached)

My question is how do you construct the message and send it to the pos using

comport.Write(msg);

?

Please i need ideas

This post has been edited by ibnmvungi: 20 July 2016 - 11:03 AM


Is This A Good Question/Topic? 0
  • +

Replies To: sending a packet to serial (RS232 Communication)

#2 Curtis Rutland   User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 5106
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

Re: sending a packet to serial (RS232 Communication)

Posted 20 July 2016 - 11:08 AM

You can just pass a string. SerialPort.Write, one of the overloads takes a string. You mention "image attached", but there isn't any image attached.
Was This Post Helpful? 0
  • +
  • -

#3 ibnmvungi   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 93
  • Joined: 20-April 12

Re: sending a packet to serial (RS232 Communication)

Posted 20 July 2016 - 11:23 AM

View PostCurtis Rutland, on 20 July 2016 - 11:08 AM, said:

You can just pass a string. SerialPort.Write, one of the overloads takes a string. You mention "image attached", but there isn't any image attached.


Edit: Removed high level packet format.

I also sound these parameters as required

The table below has a structure of the Request and Confirmation messages sent from ECR to POS.
Edit: Removed sample low level packet format.


Also some more details details

Edit: Removed definition of terms.

Can you give me some message format as described above?
Was This Post Helpful? 0
  • +
  • -

#4 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7528
  • View blog
  • Posts: 25,317
  • Joined: 05-May 12

Re: sending a packet to serial (RS232 Communication)

Posted 20 July 2016 - 11:32 AM

We will not do your work for you.

The documentation tells you exactly how the data is to be formatted and sent. If you don't understand this documentation, work with your manager or your peers to learn the details.

On a high level, it looks like the device wants data sent in a binary format rather than a string. You'll need to write out a series of bytes, and expect data to come back the same way.
Was This Post Helpful? 1
  • +
  • -

#5 ibnmvungi   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 93
  • Joined: 20-April 12

Re: sending a packet to serial (RS232 Communication)

Posted 20 July 2016 - 11:49 AM

View PostSkydiver, on 20 July 2016 - 11:32 AM, said:

You'll need to write out a series of bytes, and expect data to come back the same way.


That is what i wanted to know. "How to write data?"
Thanks
Was This Post Helpful? 0
  • +
  • -

#6 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7528
  • View blog
  • Posts: 25,317
  • Joined: 05-May 12

Re: sending a packet to serial (RS232 Communication)

Posted 20 July 2016 - 12:19 PM

Did you even look at the documentation? SerialPort.Write Method (Byte[], Int32, Int32)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1