Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7727365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:26:28+00:00 2026-06-01T05:26:28+00:00

I have a MT2070 scanner that needs to communicate to a PC app (send

  • 0

I have a MT2070 scanner that needs to communicate to a PC app (send and receive). I have got the sending from the scanner to the PC going using ScannerServicesClient.SendLabel in the Symbol.MT2000.ScannerServices assembly.

I have not had any success however in receiving data sent from the PC intended for the scanner. I haven’t managed to find anything in the Symbol.MT2000 assemblies that look like handling this or have I found any examples for receiving data.

If anyone can point me to an example or knows how I can achieve this it would be much appreciated.

private readonly SerialPort _port = new SerialPort()

private void SetupPort()
{
  _port.PortName = "COM1";
  _port.BaudRate = 9600;
  _port.DataBits = 8;
  _port.Parity = Parity.None;
  _port.StopBits = StopBits.One;

  try
  {
    _port.Open();
    _port.DataReceived += PortDataReceived;
    _port.ErrorReceived += PortErrorReceived;
  }
  catch (Exception Ex)
  {
    OnCommsMessage("Exception opening port: " + Ex.Message);
  }
}

private void PortDataReceived(object sender, SerialDataReceivedEventArgs e)
{
  OnCommsMessage("PortDataReceived");
}

private void PortErrorReceived(object sender, SerialErrorReceivedEventArgs e)
{
  OnCommsMessage("PortErrorReceived");
}

DataReceived never seems to be raised. Using SerialPort.GetPortNames() gives me COM1,COM2,COM4,COM5,COM9,$device\COM21,$device\COM23. I have tried setting the port to all of those except the last two (not sure if I’m supposed to add some device name for those)

UPDATE

Working solution

internal class MT2000CradleCommunicator : BaseCradleCommunicator
{
private readonly ScannerServicesClient _scannerServicesClient = new ScannerServicesClient();


public override void Start()
{
  if (_scannerServicesClient.Connect(true))
  {
    OnCommsMessage("ScannerServicesClient Connected");
    SetRawMode();
  }
  else OnCommsMessage("ScannerServicesClient Failed to connect");
}

public override void Send(string message)
{
  RESULTCODE result = _scannerServicesClient.SendRawData(MessageToRawData(message), 1000);
  if (result == RESULTCODE.E_OK)
  {
    Receive();
  }
  else OnCommsMessage("Error sending data: " + result);
}

private void SetRawMode()
{
  const int ATTRIBUTE_NUM_WIRED_HOST_NUM = 383;
  const byte API_HOST_RAW = 18;

  ScannerHostParameters hostParameters = new ScannerHostParameters(_scannerServicesClient);
  RawParameters rawHostParameters;
  RESULTCODE result = hostParameters.GetRawParameters(out rawHostParameters);
  if (result == RESULTCODE.E_OK)
  {
    rawHostParameters.Type = RawParameters.RawHostType.RS232;
    rawHostParameters.BaudRate = RawParameters.RawBaudRates.RAWSERIAL_9600;
    result = hostParameters.StoreRawParameters(rawHostParameters);
    if (result != RESULTCODE.E_OK)
      OnCommsMessage("Set Parameters failed: " + result);
  }
  else OnCommsMessage("GetParams failed: " + result);

  byte wHostNum;
  result = _scannerServicesClient.GetAttributeByte(ATTRIBUTE_NUM_WIRED_HOST_NUM, out wHostNum);
  if (result == RESULTCODE.E_OK)
  {
    OnCommsMessage("Get host: " + wHostNum);
    result = _scannerServicesClient.SetAttributeByte(ATTRIBUTE_NUM_WIRED_HOST_NUM, API_HOST_RAW);
    if (result != RESULTCODE.E_OK)
      OnCommsMessage("Set host failed: " + result);
  }
  else OnCommsMessage("Get host failed: " + result);
}

private static RawData MessageToRawData(string message)
{
  byte[] bytes = Encoding.ASCII.GetBytes(message);
  return new RawData(bytes, bytes.Length, 1);
}

private void Receive()
{
  RawData rawData;
  RESULTCODE result = _scannerServicesClient.ReadRawData(out rawData, 5000);
  if (result == RESULTCODE.E_OK)
  {
    OnCradleMessageReceived(BytesToAsciiString(rawData.Data));
  }
  else
  {
    OnCommsMessage("Comms timeout: Failed to receive data");
  }
}

private static string BytesToAsciiString(byte[] data)
{
  return Encoding.ASCII.GetString(data, 0, data.Length);
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T05:26:29+00:00Added an answer on June 1, 2026 at 5:26 am

    Not sure if you still need an answer for your MT2070 problem — there’s a method called ReadRawData to read from the computer.

    Also, it needs to be in Raw mode, using something like:

    myScannerSvcClient.SetAttributeByte(
        (ushort)ATTRIBUTE_NUMBER.ATT_MIA_HOSTNUM,
        (byte)ENUM_HOSTS.HOST_RAW
        );
    

    Also also, if you’re using Bluetooth SPP this won’t work. Needs to be through the cradle (if you have one) or direct to the USB cable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have an app that can use tts to read text messages. It can also
Have a rails app that is supposed to display a list of products/managers. After
Have a (rather complex) app that works fine on iOS 4 but fails on
Have just started using Google Chrome , and noticed in parts of our site,
Have just started using Visual Studio Professional's built-in unit testing features, which as I
Have you refactored from an ActiveRecord to a DataMapper pattern? What conditions prompted the
Have converted devise new session from erb to Haml but doens't work, this is
Have a bunch of WCF REST services hosted on Azure that access a SQL
Have a look at this url: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:jquery_ui_methods#column_chooser I have got the Column Chooser dialog
Have finally got a responsive site working (of a fashion). What I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.