Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

VB2008 send Hex and Receive Hex (why the numbers 0 was cut? )

Status
Not open for further replies.

boyguitar1

Member level 1
Joined
Nov 8, 2010
Messages
33
Helped
12
Reputation
24
Reaction score
12
Trophy points
1,288
Activity points
1,486
Hello Sir

I have sent "C0 00 27 00 01 00 D7 C0" this is Hex number.
I short Tx and Rx pin.
when i press button send i received missing code or not completed.
"C0027010D7C0" <-- this is what recevied it was cut off the number 0

why i get this ?
Please help suggest me too..


Thank you sir..






and below is button send code:
Code:
      Dim buffer(8) As Byte

        ' C0 00 27 00 01 00 D7 C0

        buffer(0) = 192
        buffer(1) = 0
        buffer(2) = 39
        buffer(3) = 0
        buffer(4) = 1
        buffer(5) = 0
        buffer(6) = 215
        buffer(7) = 192
        SerialPort1.Write(buffer, 0, 8)
        Timer1.Enabled = True

and this is Timer1 code
Code:
        For Me.i = 0 To 254
            BRx(i) = 0
        Next
        receive_data = SerialPort1.BytesToRead
        If receive_data = 0 Then Exit Sub
        If receive_data > 255 Then
            receive_data = 255
        End If
        For Me.j = 1 To receive_data
            BRx(input) = SerialPort1.ReadByte
            txt_receive.Text = txt_receive.Text & Hex(BRx(input))
            input = input + 1
        Next
        input = 0
        Timer1.Enabled = False


        For Me.i = 0 To 254
            BRx(i) = 0
        Next

        Timer1.Interval = 1000
        Timer1.Enabled = True
 

could it be that when printing a byte value of 0 the output does not print leading 0's
for example using printf with C the conversion specification %x would display 0, to display leading 0's one would use %02x which would print 00
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top