Home > Back-end > Can't wait, DELPHI serial port to send data
Can't wait, DELPHI serial port to send data
Time:09-30
Using Delphi program SPCOMM controls, used to send and receive data is normal, then somehow there will be a serial port receives the data is not complete, receive part of the code is primarily a The begin SetLength (STR, Bufferlength); Viewstring:='; Move (buffer ^ rbuf, bufferlength); //check checksum If checksum (rbuf bufferlength)=false then exit; Below is the check processing part, and sometimes a serial port to send out the data, step through it will prompt the access violation at address 0044 d97e module in such mistakes, I don't know what's going on? Everybody to see, thank you! Here are sending code Procedure senddata publishes the event (length: integer); Var I: integer; Commflg: Boolean; The begin Viewstring:='; Commflg:=true; For I:=1 to length do The begin If not welcome.com m1. Writecommdata (@ sbuf [I], 1) then The begin Commflg:=false; break; end; sleep(2);
The easiest way to use the serial port tool, to send and receive test, to ensure that no problem of hardware and software
CodePudding user response:
Use serial debugging assistant to send and receive is normal, is to use the software will appear this problem, if you step through an error, the wrong step over and run to create the form again, then may be good, this will be the programming problem?
CodePudding user response:
You send your data, use a serial port debug tool to receive, you see if you actually send data right
CodePudding user response:
A receiving is not all it's ok, may be associated with lower machine to send, such as: the machine is continuously transmitted the data, the PC and sent an instruction to a machine, a machine under general by polling the processing instructions, if processes is not good, may be in continuous transfer when data is inserted into the return instruction, this doesn't matter, as long as the upper machine completes the length check, check check,
Send not go out, a single bad judgment from the code, still need to carefully analyze!
CodePudding user response:
Serial processing speed slow, delay to set up good, I was sleep before (100) or more, you try, and see if it is for this reason