Author Topic: nrComm tx and rx  (Read 1423 times)

kasko

  • Newbie
  • *
  • Posts: 5
    • View Profile
nrComm tx and rx
« on: July 30, 2012, 08:20:35 pm »
Hello out there!
I've just got a licenced version of the nrComm, and now I try to implement it in my project. I have tested some of the sampe programs, and they work correnct, but they don't fullfill my requirements!
Perhaps someone out there could the newbie like me some help?
Here is a description of the "problem" to solve:
My program send some commands to an external unit.
The unit responds by sending a known numer of bytes back, the respond time and transmitting data time will in some way depend on the commands sent. Sometimes, the return data will be transmitted at once and sometimes it will take some time between each batch of return data. The number of bytes will be between 4 and about 50kB as a maximum.
After all data received, the data will be processed in the pc program. This processing can not take place before all data has been received.

It seems to me that Synchronous mode should be the correct method to use, but I have problems with reading the data back to my global byte array.

I hope someone please could give me some hints in the correct direction! Thanks in advance!

Karl

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: nrComm tx and rx
« Reply #1 on: July 31, 2012, 05:39:06 am »
Hello

You need investigate more details of communication protocol with your external device (unit).
After your request device replies. You need to know packet begin and packet and chars or packed begin and packet length for correct detection long incoming data from device. Best practice is using OnAfterReceive event or TnrDataProcessor component together with RS232 component TnrComm.

See demo:
Demos\DataProc
Demos\SimplePacket

Also more please info read here
http://forums.nrcommlib.com/index.php?board=19.0

Roman Novgorodov
DeepSoftware llc
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

kasko

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: nrComm tx and rx
« Reply #2 on: July 31, 2012, 11:47:27 am »
Thank's for feedback Roman!
The feedback data does not have any start or end character or sequence. I just send a command, and I do know exactly how many bytes will be returned! Yes, I know it will be problems if I don't get the correct number of bytes back, but this have been working with other freeware com components for Delphi. :-)
Is it possible to define just the packet size?
I have already looked at the examples you mention, but I will of course look again and try more! I must be familiar with the use of the nrComm!

Karl