Home > Software engineering >  VB use a serial port to accept two different orders
VB use a serial port to accept two different orders

Time:09-25



SJS and SJLZ are hexadecimal array of instructions, want to use the same serial port to accept different instruction, don't know how to use the timer control,

CodePudding user response:

That's too chaos

CodePudding user response:

Each run will pop up to 10 seconds 380 invalid attribute value, MSComm1. The Output=SJS

CodePudding user response:

PortOpen don't write here, in the form_load best handle

CodePudding user response:

Feel you in this line of thought, not good ah,
Suggestion: myself on the Internet to see a book of serial port communication, much better;

Processing method: I use different buttons, said different data to be sent, and there should be some variables represent different status,
Timer to send can be used a similar idea (control) with a state variables,

And then to judge the data returned, can according to the state of the scalar in mscomm on_comm events processing respectively

CodePudding user response:

What do you mean two different instructions? From different hosts?

If it's just different instructions from the same host, after it receives the parsing can be carried out,

CodePudding user response:

LZ is trying to send is an array of bytes, the Byte array to a string representation of the so-called hexadecimal number form need into a Byte array, to send,
MsComm controls the OutPut attribute is the need to give the Variant data type,
The Output properties, to write the data flow transmission buffer,
Description
Output properties can transmit text data or binary data, using the Output property transfer text data, must define a contains a string of Variant, send binary data, must pass a Variant containing an array of bytes to the Output properties,
Under normal circumstances, if an ANSI string sent to the application, can be in the form of text data to send, if send include embedded control characters, Null character, and so on, to be transmitted in binary form,



CodePudding user response:

refer to 6th floor zdingyun response:
LZ is trying to send is an array of bytes, the Byte array to a string representation of the so-called hexadecimal number form need into a Byte array, to send,
MsComm controls the OutPut attribute is the need to give the Variant data type,
The Output properties, to write the data flow transmission buffer,
Description
Output properties can transmit text data or binary data, using the Output property transfer text data, must define a contains a string of Variant, send binary data, must pass a Variant containing an array of bytes to the Output properties,
Under normal circumstances, if an ANSI string sent to the application, can be in the form of text data to send, if send include embedded control characters, Null character, and so on, to be transmitted in binary form,

Astute, penetrating,
  • Related