I am using the C# language to send information to the VideoJet Dataflex 6330 printer, but without success the printer is not receiving the information that I am sending. The code I'm using is the following:
private void btnTeste_Click(object sender, EventArgs e) { string msg = ""; int _Port = 0; try { _Port = Convert.ToInt32(txtPort.Text); msg = GetVideoJet(); MessageBox.Show(msg); IPAddress ipAddr = System.Net.IPAddress.Parse(txtIP.Text); IPEndPoint localEndPoint = new IPEndPoint(ipAddr, _Port); Socket senderMsg = new Socket(ipAddr.AddressFamily, SocketType.Stream, ProtocolType.Tcp); senderMsg.Connect(localEndPoint); byte[] messageSent = Encoding.ASCII.GetBytes(msg); int byteSent = senderMsg.Send(messageSent); byte[] messageReceived = new byte[1024]; int byteRecv = senderMsg.Receive(messageReceived); msg = $"Message from Server -> {Encoding.ASCII.GetString(messageReceived, 0, byteRecv)}"; senderMsg.Shutdown(SocketShutdown.Both); senderMsg.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private string GetVideoJet() { string _ret = "SLA|TESTE"; _ret += "|FORNECEDOR=" + txtFornecedor.Text; _ret += "|PRODUCAO=" + txtProducao.Text; _ret += "|SEMANA=" + txtSemana.Text; _ret += "|DIA=" + txtDia.Text; _ret += "|<CR>"; return _ret; }
Can anyone help me and have had this problem
What I've tried is not to convert the string into bytes and what I hope is that someone here on the forum has already had this problem and can help me. Thanks.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)