I took a look at the AK protocol and this is a request/response type protocol. Bens code is good for reading from devices that transmit on their own, but is not what you need to talk to your instrument.
Here is something that should get you started. I haven’t tested this, as I don’t have the hardware that you have. You also need to check for error codes and add what ever logic you need to trigger the communications when you need to. This is setup to retrieve the serial # of the instrument.
//commHandle is a variable in PAC Control of type communication handle.
//You should already have configure the serial module through PAC Manager for the baud rate, stop bit, and parity (9600 8n1).
//This should be set one time (in your powerup maybe), or can be setup as the initial value when you create the variable
SetCommunicationHandleValue("tcp:146.30.101.143:22518", commHandle);
//Initialize some protocol constants, only need to do this once
sSTX = Chr(2);
sETX = Chr(3);
//Here is some code to send a command and parse the response
//You will want to add additional logic to this for error handling and so forth
if (GetNumCharsWaiting(commHandle) < 0 or not IsCommunicationOpen(commHandle)) then
nResult = OpenOutgoingCommunication(commHandle);
SetEndOfMessageTerminator(commHandle, 3); //ASCII 3 per protocol
else
ClearCommunicationReceiveBuffer(commHandle);
endif
//Build a command - I'm going to use some variables to make this easier
//That way you can just change the following values for other commands
sFunction = "AKEN";
sChannel = "2";
sParameters = "";
//Put the above command together into a request to send out the port
sRequest = sSTX + "_" + sFunction + " K" + sChannel + " " + sParameters + sETX;
//This is a built in fucntion that makes it easy for command/response type protocols
nResult = TransmitReceiveString(sRequest, commHandle, sResponse);
//SHOULD check nResult here for errors
//Parse response
//Find the end of the string where the ETX is (could also use string length since it should
//always be the last character
nEndPos = FindCharacterInString(3, 0, sResponse);
//Grab the payload starting at byte 10 (index 9) to the ETX according to the protocol
//sPayload should have the response to the command.
GetSubstring(sResponse, 9, nEndPos - 9, sPayload);