Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serial connection problem #78

Open
BluesCool opened this issue Jul 16, 2023 · 0 comments
Open

Serial connection problem #78

BluesCool opened this issue Jul 16, 2023 · 0 comments

Comments

@BluesCool
Copy link

After I use this plug-in to open the serial port com1, the message information displayed on the serial tool is incorrect. I sent aa06000000000000000000ff, but the serial tool shows 00 80 80 80 00 00 00 00 00 00 00.
Then I used the serial port tool to open com1, then closed it, and then used the plug-in to open com1, and the sent message was displayed on the serial port tool, and whatever I sent was displayed. What is the reason.

code show as below:
void open(String portName, int baudRate) async {
_serialPort = SerialPort(portName);
var config = SerialPortConfig();
config.baudRate = 9600;
config.parity = 0;
config.bits = 8;
// config.cts = 0;
// config.rts = 0;
config.stopBits = 1;
config.xonXoff = 0;
_serialPort!.config = config;
_readData();
}

void sendData(String sendData) async {
List dataList = [];
int len = sendData.length ~/ 2;
for (int i = 0; i < len; i++) {
String data = sendData.trim().substring(2 * i, 2 * (i + 1));
int? d = _hexToInt2(data);
dataList.add(d!);
}
var bytes = Uint8List.fromList(dataList);
_serialPort!.write(bytes);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant