Click here to Skip to main content
15,887,434 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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 have tried:

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.
Posted
Updated 19-Dec-22 1:39am

1 solution

Talk to the manufacturers - their tech support will be much more familiar with the hardware than we are, and will likely have sample code that should work out-of-the-box to use as a basic starter.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900