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.

Why my data lost on rs-232 ?

Status
Not open for further replies.

winit_a

Junior Member level 1
Joined
Nov 16, 2003
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
142
my program is communication send files or chat on rs-232 (cross line)
used MSCOM control on Visual Basic 6 with Sp5

I read file size and send until end of file
I counter byte file to send = files size = OK
but Recieve side Receive data less than Send = error
I don't know error why recieve data less than Send

Send side
'===========================================================
tFileNumber = FreeFile
File_Ptr = 1
File_Ptr_Tmp = 1
Open AFileName For Binary As tFileNumber
Do While Loc(tFileNumber) < FileSize
tDataSendBuffer = Input(1, #tFileNumber)
tMessage = tMessage + tDataSendBuffer
Statusbar.Panels.Item(2).Text = "Sending file... " + tDataSendBuffer
DoEvents
RS232Comm.Output = tDataSendBuffer
pgb1.Value = Loc(tFileNumber)
Statusbar.Panels.Item(1).Text = CStr(Loc(tFileNumber)) + "/" + CStr(FileSize)
Loop
Close tFileNumber

Receive side
'============================================================
Open AFileName For Binary As tFileNumber
on event receive
Put #tFileNumber, File_Ptr, Asc(ADataRecieveBuffer)
File_Ptr = File_Ptr + 1

Thank you
 

Hi,
First of all, check you physical link. Send a large file using hyperterminal, zmodem protocol to the other side, using the same cable, and same speed like in your app. After completion (if succesfull), check the number of errors from z-modem window. If the number is 0, then the bug is in your program. If not, your connection is lossy. I had the same problem with data loss between a pc and a laptop, and the problem was a long cable with poor shielding running at 115200.
Best,
 

Other possibilities if you don't use flow control (hardware or XON XOFF), the receiver just can't handle the flow. In fact it can be just FIFO parameters to adjust. At 115200 bauds (8N1), if there is no FIFO, an IT should be service before 86 µs (1/115200), so when multitask os is used, it sometimes too low.
With 16 bits FIFO, this time grown to 86*16 = 1.3 ms. Its not as critic as first one
 

I met the same problem before. But finally I solved it by slow down the speed (adding delay between each byte).
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top