0

I'm trying to read data sent through a serial port by an NCR 7878 scanner/scale.

I'm using Visual Basic .NET, I can get the barcode data just fine, using the serial port ReadExisting function. so with the scanner I'm good, the problem is that in order to get the weigh value, I must send some value to the scale, so it knows when to send the weigh value back, (I have no idea what value, i have googling a lot trying to find a library or something, no luck) please if you have some experience with this or know about a library that I can Use.

The Code I use to read, just in the testing is pretty simple:

Private Sub SerialPort1_DataReceived(sender As Object, e As SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
        Try
            Dim sp As SerialPort = sender

            _DataReaded4 = sp.BytesToRead
            _DataReaded2 = sp.ReadByte()
            _DataReaded3 = sp.ReadChar()
            _DataReaded = sp.ReadExisting()

            '  SerialPort1.Read("", 0, 5)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
Joel Chavez
  • 3
  • 1
  • 3
  • So, your question is effectively what value do you need to send to this scale to tell it to report the weight? – jmcilhinney Aug 12 '21 at 01:58
  • Yes, that would be helpful, I've tried some that I found in manuals of other models but no luck so far. I know I have to send an HEX code. – Joel Chavez Aug 12 '21 at 05:04
  • I doubt that you know anything of the sort. Hex is generally a means to display binary data in a human-readable form, where each pair or hexadecimal digits represents a single byte. More likely, what you actually have to send is the bytes. If you are sending a hex code as text then that may be your issue. – jmcilhinney Aug 12 '21 at 05:14
  • Well, I'm not dumb, I know how what hex is, and no, I'm not sending it as string, I know how to write hex to the port, I've tried several codes that I found in a manual, but unfortunately those codes were for a different model, but I was hopping they would work... So no suggestion? – Joel Chavez Aug 13 '21 at 06:12
  • *"no, I'm not sending it as string"*. Then you're not sending hex. You are sending bytes. Hex is just a way to represent bytes to human beings. There's no hex involved so, while I have no idea whether or not you're dumb, it's clear that either you don't know what hex is or else you don't understand the mechanism by which data is being sent. All people have things that they don't know or understand so there's no shame in that, but insisting that you do understand them and then displaying that you don't doesn't really help anyone. – jmcilhinney Aug 13 '21 at 06:31
  • It's kind of late at this point but I was able to figure it out, turns out there's a library that you can download and use it in your project, it has examples on how to use it. I don't remember where I doewnloaded it from but here's the link if somebody needs it in the future: https://drive.google.com/file/d/1G9Zt35P9u89dioOerMd5N1Luz5MXGlTn/view?usp=sharing Worked like a charm for me. hope it helps someone else. – Joel Chavez Nov 20 '21 at 21:32

1 Answers1