views:

182

answers:

4

I am working on write a program that reads and writes from the barcode my problem when writing (send command to barcode)

I read in pdf manufacturer barcode that the command of capturing the image is IMGSNP so i pass it to write function as follows serialPortObj.write ("IMGSNP")

But Why does not have a barcode to respond to the command ? and did not capture the image :( Is this wrong way (I have in some cases may need to take image Not for barcode it self but image for passport or product etc.. Which doesn't contains a barcode ) Barcode manufacturer is HandHeld (4800p) Thanks for any help

here is my code

    private  SerialPort Com ;        
    private delegate void DataReadDel(string Text);

    private void Form1_Load(object sender, EventArgs e)
    {
        Com = new SerialPort("COM4");
        Com.Open();
        Com.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
    }
    private void port_DataReceived(object sender,SerialDataReceivedEventArgs e)
    {
        Com.Encoding = Encoding.Default;
        this.BeginInvoke(new DataReadDel(DataReceived), new object[] {Com.ReadExisting() });
    }
    private void DataReceived(string dR)
    {
        textBox1.Text = dR;
    }
    private void button1_Click(object sender, EventArgs e)
    {
        if (! Com.IsOpen )
        {
            Com.Open();
        }
        Com.Write("IMGSNP1B1L");
        Com.Write("IMGSHP");
        string imgbytes = Com.ReadExisting();// return ""
    }
A: 

Are you sure that the barcode reader is not capturing the image? According to the documentation:

An image is taken when the Image Snap (IMGSNP) command is processed. The last image is always stored in memory. You may “ship” the image by using the IMGSHP command.

So you may be taking the image using IMGSNP, but all that's happening is that its storing the image in memory, and not sending it back to you as a response. Try then issuing the IMGSHP command, and see if there's any data to be read from your serial port.

Pandincus
Thank you very much especially for Mr.Pandincus and sorry for the delay in reply In fact,i have used all the command but the problem is that the barcode did not respond to a command (even it did not launch light reading or beebing) I have corresponded with the manufacturer and I await a reply if there are any suggestions Many Thanks :)
DaniAm
Could you edit your original question to include some sample code?Are you sure that it didn't respond, beyond the light and beeping?It says in the manual that by default the beep and LED is disabled by default when using IMGSNP.
Pandincus
Thanks alot Pandincus, once again sorry for the delayI've added my code
DaniAm
A: 

As well as the command itself, do you have to provide any termination characters?

A common method is to wrap the command packet in STX and ETX characters so the barcode reader will know when a full command has been received, or possibly just terminate with a carriage return (CR) and linefeed characters (LF). You need to check the specs.

Also, since you are sending a string, encoding may be important, and I would expect the barcode reader needs ASCII characters sent to it, but again, you should check the unit to be sure.

I suspect the easiset way to send a command is to send it as an array of bytes, which makes it easier to use the STX, ETX, CR or LF characters if necessary, as these are non-printable characters and have the following values:

STX = 0x02, ETX = 0x03, CR = 0x0D, LF = 0x0A

Andy
Thanks alot about your remark Mr.Andyi try thisString dataSent = "IMGSNP";//Image snap command byte[] dS = Encoding.ASCII.GetBytes(dataSent); Com.Write(dS,0,dataSent.Length ); dataSent = "IMGSHP";//Image shipper command dS = Encoding.ASCII.GetBytes(dataSent); Com.Write(dS, 0, dataSent.Length);but ':( Not Respondany suggestion i appreciate your time
DaniAm
The manual says on page 1-5 that you need to download a driver to use the USB COM port emulation mode when using Windows.
Andy
Mr.Andy the barcode reader(scanner) works and it can read the barcode , but i want to make it take image (I have in some cases may need to take image Not for barcode it self but image for passport or product etc.. Which doesn't contains a barcode )thanks :)
DaniAm
A: 

You need to send the Serial command header along with the IMGSNP command to have the scanner capture and send the image. The header is three ASCII characters: SYN M CR (ASCII 22,77,13).

Pete
A: 

DaniAm, any solution so far?