dtnghia
Posts: 24
Joined: Thu Sep 18, 2008 8:54 pm
Location: Vietnam

PDA Problem

Thu Dec 11, 2008 2:19 pm

Hi,

I used Bluetools to create Serial Port Service on PDA and created Sending Client at PC, i faced problem as:

- If PC send file which has size < 3K. PDA can receive totally.
- If PC send file which has size > 3K ( e.g 5.3K). PDA only receive approximately 3K.

All source code, i use from Bluetool examples.

Please help me.

Thanks

Jonas
Posts: 2319
Joined: Mon Jan 09, 2006 2:20 pm
Location: Sweden

RE: PDA Problem

Thu Dec 11, 2008 3:03 pm

Possibly you are overflowing some buffer if you are sending data over the serial port (if that's what you're doing?)
Try sending smaller packages (<3K)

Regards,
Jonas

dtnghia
Posts: 24
Joined: Thu Sep 18, 2008 8:54 pm
Location: Vietnam

RE: PDA Problem

Thu Dec 11, 2008 6:28 pm

Hi Jonas,

On PC , i used below code lines to send

DataStream selectedStream = new DataStream(currentStream);
currentStream.BeginWrite(bytes, 0, bytes.Length, new AsyncCallback(wCallback), currentStream);
currentStream.Flush();


....

And on PDA, the source code is:


byte[] buffer = new byte[20];
connectedStream.BeginRead(buffer, 0, buffer.Length, new AsyncCallback(readCallback), connectedStream);

with readCallback function in your document.

So can you guide me which way i may follow to sending smaller packages (<3K)?

Thanks

Jonas
Posts: 2319
Joined: Mon Jan 09, 2006 2:20 pm
Location: Sweden

RE: PDA Problem

Thu Dec 11, 2008 6:32 pm

Use currentStream.Write or currentStream.BeginWrite together with EndWrite.

Then don't pass bytes.Length but just part of the buffer. When Write returns (or EndWrite) all those bytes in the buffer will have been written. Then pass some more bytes etc. I guess your "bytes" is a large buffer?

Regards,
Jonas

dtnghia
Posts: 24
Joined: Thu Sep 18, 2008 8:54 pm
Location: Vietnam

RE: PDA Problem

Fri Dec 12, 2008 11:17 am

Hi Jonas,

I followed your suggestion and tried to send each package size = 100 bytes, The PDA could receive more than 3K. But still not total of file.
E.g : - if i send 5.52 K, PDA can receive total of file
- if i send 15K, PDA just only receive 80%.


Thanks,

Jonas
Posts: 2319
Joined: Mon Jan 09, 2006 2:20 pm
Location: Sweden

RE: PDA Problem

Fri Dec 12, 2008 12:15 pm

Post more of your code, or try another PDA to see if it's hardware dependent.

Regards,
Jonas

dtnghia
Posts: 24
Joined: Thu Sep 18, 2008 8:54 pm
Location: Vietnam

RE: PDA Problem

Sat Dec 13, 2008 7:49 am

Hi Jonas,

When i add "Thread.Sleep(100);" before "currentStream.EndWrite(result); " of each packet. PDA can receive 100% of file. If the invoked function wcallBack in AsyncCallback(wcallBack) work well?.

Thanks

Return to “BlueTools”