JDL129
asked on
Communications with device using STX/ETX/LRC
Hey guys!!
I am trying to communicate with an Ingenico iSC350 and I need some help with the following string.
STX control character
1 byte
Message Identifier
3 bytes
Message data, consisting of multiple fields
n bytes (0 to 241)
ETX control character
1 byte
LRC check character
1 byte
How do I go about this?
Thanks,
Jerry
I am trying to communicate with an Ingenico iSC350 and I need some help with the following string.
STX control character
1 byte
Message Identifier
3 bytes
Message data, consisting of multiple fields
n bytes (0 to 241)
ETX control character
1 byte
LRC check character
1 byte
How do I go about this?
Thanks,
Jerry
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a bunch!!!!!!!!!!!!!111
How your PC connect to Ingenico iSC350? Com (serial port) or IP (Socket, NET)? Can you post the code you have send/receive data? Do you receive a byte [] or string data?
ASKER
minhvc!!!!!!!!!!!!!!!!!!!! !!
Thanks for the post!!!!!!!!!
It connects by usb: RemoteHost is 127.0.0.1 and RemotePort is 5446 and it has a Telnet button beside the Host and Port fields.
When I parse the received data it appears to be the same format as you have suggested we send.
This is the code we're trying to use:
using System;
using System.Collections.Generic ;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net.Sockets;
using System.IO;
using System.Threading;
using System.Net;
namespace iSC350
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
TcpListener listener = null;
private void btnSend_Click(object sender, EventArgs e)
{
string strMsg = "<STX>"+txtMessage.Text+"< FS>"+txtBo xId.Text+" <FS>7699<E TX><LRC>";
TcpClient tcpClient = new TcpClient();
tcpClient.Connect("127.0.0 .1", 5446);
NetworkStream Streamtest = tcpClient.GetStream();
Byte[] outbytes = System.Text.Encoding.Defau lt.GetByte s(strMsg.T oCharArray ());
Streamtest.Write(outbytes, 0, outbytes.Length);//Sned data to ISC350 port
tcpClient.Close();
}
private void AcceptWorkThread()
{
while (true)
{
Socket socket = listener.AcceptSocket();
byte[] buffer = new byte[1024];
int receiveCount = socket.Receive(buffer);
if (receiveCount > 0)
{
string recString = Encoding.UTF8.GetString(bu ffer, 0, receiveCount);
MessageBox.Show(recString, "ISC350 Port get data.");
}
else
{
}
}
}
private void Form1_Load(object sender, EventArgs e)
{
listener = new TcpListener(new IPEndPoint(IPAddress.Parse ("127.0.0. 1"), 5446));
listener.Start();//Listen ISC350 port if get data
Thread acceptThread = new Thread(new ThreadStart(AcceptWorkThre ad));
acceptThread.Start();
}
}
}
Thanks again for the help!!!
Jerry
Thanks for the post!!!!!!!!!
It connects by usb: RemoteHost is 127.0.0.1 and RemotePort is 5446 and it has a Telnet button beside the Host and Port fields.
When I parse the received data it appears to be the same format as you have suggested we send.
This is the code we're trying to use:
using System;
using System.Collections.Generic
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net.Sockets;
using System.IO;
using System.Threading;
using System.Net;
namespace iSC350
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
TcpListener listener = null;
private void btnSend_Click(object sender, EventArgs e)
{
string strMsg = "<STX>"+txtMessage.Text+"<
TcpClient tcpClient = new TcpClient();
tcpClient.Connect("127.0.0
NetworkStream Streamtest = tcpClient.GetStream();
Byte[] outbytes = System.Text.Encoding.Defau
Streamtest.Write(outbytes,
tcpClient.Close();
}
private void AcceptWorkThread()
{
while (true)
{
Socket socket = listener.AcceptSocket();
byte[] buffer = new byte[1024];
int receiveCount = socket.Receive(buffer);
if (receiveCount > 0)
{
string recString = Encoding.UTF8.GetString(bu
MessageBox.Show(recString,
}
else
{
}
}
}
private void Form1_Load(object sender, EventArgs e)
{
listener = new TcpListener(new IPEndPoint(IPAddress.Parse
listener.Start();//Listen ISC350 port if get data
Thread acceptThread = new Thread(new ThreadStart(AcceptWorkThre
acceptThread.Start();
}
}
}
Thanks again for the help!!!
Jerry
How recString you received from device?
ASKER
minhvc!!!!!!!!!!!
We haven't got to there yet. Any ideas?
Thanks again,
Jerry
We haven't got to there yet. Any ideas?
Thanks again,
Jerry
ASKER
What you have sent is exactly what I need. I have some data to send and I would appreciate it if you can put it in the format above.
My open message is 01.00000000
My close message is 00.0000
STX an ASCII control Character, Type is Constant, and length is 1
Message Identifier is ASCII "01." for open message
Application ID is Decimal 0000
Parameter ID is Decimal 0000
ETX is an ASCII control Character Type is Constant, length is 1
LRC check character is Binary, length is 1
When it is sent it looks like 01.00000000
When I run int i = strMsg.IndexOf(ETX); i is -1.
I don't think I have items in the proper order.
Again I appreciate the post!!!!
Jerry