Zdravím všetkých, posielam data z eepromky cez atmegu16 do PC cez seriovu linku a chcem ich zapisať do Listboxu. Jedna sa o 8 bajtove bloky ktoré sú posielané zasebou. Problém mam v tom že do listboxu mi data zapiše sice spravne ale nie po 8 bajtov al ako sa mu chce pre priklad uvadzam vypis listboxu: 000000000000000011111111111111112222222222222222 33333333333333334444444444444444555555555555555566666666666666 66777777777777777788888888888888889999999999999999AAAAAAAAAA AAAAAABBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCDDDDDDDDDDDDD DDDEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFFF0000000000 0000001111111111111111222222 222222222233333333333333334444444444444444555555555555 555566666666666666667777777777777777888888888888 88889999999999999999 AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCDDDDDDDDDDDDDD DDEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFFF... a ja to chcem aby mi to v jednom riadku zobrazilo 8 bajtov čiže 16 znakov... Na nete som nasiel niečo take:
Dim WithEvents COMPort As New SerialPort
Dim LookUpTable As String = "0123456789ABCDEF"
Dim RXArray(128) As Char ' Text buffer. Must be global to be accessible from more threads.
Dim RXCnt As Integer
Private Sub Receiver(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs) Handles COMPort.DataReceived
Dim RXByte As Byte
'Do
RXCnt = 0
Do
RXByte = COMPort.ReadByte
RXArray(RXCnt) = LookUpTable(RXByte >> 4) ' Convert each byte to two hexadecimal characters
RXCnt = RXCnt + 1
RXArray(RXCnt) = LookUpTable(RXByte And 15)
RXCnt = RXCnt + 1
Loop Until (COMPort.BytesToRead = 0)
Me.Invoke(New MethodInvoker(AddressOf Display)) ' Start "Display" on the UI thread
'Loop Until (COMPort.BytesToRead = 0) ' Don't return if more bytes have become available in the meantime
End Sub
Private Sub Display()
ListBox1.Items.Add(New String(RXArray, 0, RXCnt))
End Sub
vedel by mi s tým niekto pomôcť ? Vďaka
|