Puzzling serial protocol errors for 12v12 jrk controller

I’ve been developing some code using the 12v12 jrk controller to control a windshield wiper motor. Everything worked fine, and in fact still does. But I noticed in the jrk configuration utility that I am now getting a serial protocol error.

Since that error is disabled, the error count just goes up but the motor continues running. In fact, the motor does exactly what it is supposed to do. So the error must be happening only once in several cases. Or maybe it is a “ghost” error that gets counted but does not really exist.

I did not used to get this error, and I’m not sure when this error started appearing. My code runs in Microsoft Visual Studio C++ and sends a two-word data signal through COM5 operating as a serial port. Somehow that code is now defective.

Since the code works now, I could just ignore the issue. But I would like to clear it up instead of ignore it. My worst fear is that it indicates some problem with the jrk controller. I already burned out a simple motor controller, and hope that is not happening here.

Thank you.

Hello, Daanii. The jrk’s user’s guide documents the meaning of this error:

It’s unlikely that this indicates a problem with the jrk.

You are probably sending invalid bytes to the jrk in your code. Could you simplify your code to the simplest possible thing that causes the error and post it here?


Thanks for the prompt reply, David. Here is the code (slimmed down as much as possible) that causes the error.

#include <Windows.h>
#include <iostream>
#include <MMSystem.h>
#include <stdio.h>
#include <tchar.h>

using namespace std;

int main()
	HANDLE hSerial;										// set up COM5 as serial port for writing to motor controller

	hSerial = CreateFile(_T("COM5"),

			cout<<"serial port does not exist.\n";
	cout<<"some other error occurred.\n";
	DCB dcbSerialParams = {0};

	dcbSerialParams.DCBlength = sizeof(dcbSerialParams);

	if (!GetCommState(hSerial, &dcbSerialParams)) {
		cout<<"error getting state.\n";

	dcbSerialParams.BaudRate = CBR_9600;
	dcbSerialParams.ByteSize = 8;
	dcbSerialParams.StopBits = ONESTOPBIT;
	dcbSerialParams.Parity = NOPARITY;

	if(!SetCommState(hSerial, &dcbSerialParams)){
		cout<<"error setting serial port state.\n";
	COMMTIMEOUTS timeouts={0};

	if(!SetCommTimeouts(hSerial, &timeouts)){
		cout<<"error setting timeouts.\n";

		unsigned char WriteBuffer[2];

		DWORD BytesWritten = 0;
		boolean done = false;

		int	Steer;

		while (done == false) {
		Steer = 0;

		WriteBuffer[0] = unsigned char (0xc0 + (Steer & 0x1F));			// change the signal to conform to jrk motor controller
		WriteBuffer[1] = unsigned char (Steer >> 5) & 0x7F;				//      two-word target signal

		if(!WriteFile(hSerial, &WriteBuffer, 4, &BytesWritten, NULL)){
			//error occurred. Report to user.
			cout<<"error writing T2 \n";
	int throwAway;

Why did you choose 4 for the third argument to WriteFile?


Thanks, David. That was the problem. I’m not sure how that argument got changed from 2 to 4, but changing it back to 2 does solve the problem.

That’s a great help. Thanks again.