AX500 RS232 issue in Ubuntu linux

8 years 9 months ago #29526127 by rajkum
Hi,

I am using Ubuntu of my PC and AX500 as the controller. I am able to communicate to AX500 using windows PC roborun utility, but not able to communicate with it when switched to Ubuntu Linux.

When I write ?V(for that matter anything) to the serial port, I am not getting any response from the controller. Actually I am getting the error \"RQ_ERR_SERIAL_RECEIVE\"

I try connecting to the controller using microcom, but no luck. Is there anything else that I need to configure?

Pls help me!!!

thanks,
-Rajesh

Please Log in or Create an account to join the conversation.

8 years 9 months ago #29526131 by rajkum
Hello experts, pls help me urgently!!! I can\'t proceed anything further due to this RS232 connectivity problem...

Please Log in or Create an account to join the conversation.

8 years 9 months ago #29526135 by roboteq
Replied by roboteq on topic Re:AX500 RS232 issue in Ubuntu linux
If you can comminicate with a Windows PC, there is no reason it will not work with a Linux PC.

You must make sure you have the correct communication setting:

9600bps, 7 bit, even parity, 1 stop bit, no flow control.

When sending commands, make sure that they are terminated with a Carriage return (0x0D) and not with a Line Feed (0x0A).

If this still doesnt work, look on the internet for generic help on how to make the PC com port working with Minicom.

Please Log in or Create an account to join the conversation.

8 years 9 months ago #29526137 by kab
I also had some problems with Ubuntu, because the \"Gigabyte motherboard\" drivers provided by Ubuntu were not 100% fit, and the serial port was simply not working.

It worked on another Ubuntu (on a different MB).

On Windows you have the Roboteq tool that manages to communicate with the controller.
On Linux on the other hand, you have to get the programs to match exactly the controller requirements (see post above).

I had to modify the roboteq C program which was totally outdated in order to match my controller (sdc2130). Not sure about yours, but I would check the code anyway.

Please Log in or Create an account to join the conversation.

8 years 9 months ago #29526143 by rajkum
Microcom issue:
After so many attempts, I could now see something is getting constantly printed continuously in my microcom window from the AX500 controller, as below

6000��:0000000000��0000�Ƹ�3966000��:0000000000��0000�Ƹ�3966000��:0000000000��0000�Ƹ�3966000��:0000000000��0000�Ƹ�3966000��:0000000000��0000�Ƹ�3966000��:0000000000��0000�Ƹ�3966000��:0000000000��0000�Ƹ�3966000��:0000000000��0000�Ƹ�3966000��:0000000000��0000�Ƹ�3966000��:0000000000��0000�Ƹ�3966000��:0000000000��0000�Ƹ

However, when I issued command such as ?V to the controller, no effect is found, except it continuously printing the above number.

How do I set word size to bit, parity and stop bit for microcom?

My program issue:

Pls find below my program snippet. It is primarily copied from Roboteq linux api;

//Initialization part
void RoboteqDevice::InitPort()
{
if(!IsConnected())
return;

//Get the existing Comm Port Attributes in cwrget
int BAUDRATE = B9600;
struct termios newtio;
tcgetattr (handle, &newtio);

//Set the Tx and Rx Baud Rate to 9600
cfsetospeed (&newtio, (speed_t)BAUDRATE);
cfsetispeed (&newtio, (speed_t)BAUDRATE);

//Enable the Receiver and Set local Mode
newtio.c_iflag = IGNBRK; /* Ignore Break Condition & no processing under input options*/
newtio.c_lflag = 0; /* Select the RAW Input Mode through Local options*/
newtio.c_oflag = 0; /* Select the RAW Output Mode through Local options*/
newtio.c_cflag |= (CLOCAL | CREAD); /* Select the Local Mode & Enable Receiver through Control options*/

//Set Data format to 7E1
newtio.c_cflag &= ~CSIZE; /* Mask the Character Size Bits through Control options*/
newtio.c_cflag |= CS7; /* Select Character Size to 7-Bits through Control options*/
newtio.c_cflag |= PARENB; /* Select the Parity Enable through Control options*/
newtio.c_cflag &= ~PARODD; /* Select the Even Parity through Control options*/

//cwrset.c_iflag |= (INPCK|ISTRIP);
//cwrset.c_cc[VMIN] = 6;

//Set the New Comm Port Attributes through cwrset
tcsetattr (fd0, TCSANOW, &newtio); /* Set the attribute NOW without waiting for Data to Complete*/
}

//Connecting the port and sending command section
int RoboteqDevice::Connect(string port)
{
if(IsConnected())
{
cout<<\"Device is connected, attempting to disconnect.\"<<endl;
Disconnect();
}

//Open port.
cout<<\"Opening port: \'\"<<port<<\"\'...\";
handle = open(port.c_str(), O_RDWR |O_NOCTTY | O_NDELAY);
if(handle == RQ_INVALID_HANDLE)
{
cout<<\"failed.\"<<endl;
return RQ_ERR_OPEN_PORT;
}

cout<<\"succeeded.\"<<endl;
fcntl (handle, F_SETFL, O_APPEND | O_NONBLOCK);

cout<<\"Initializing port...\";
InitPort();
cout<<\"...done.\"<<endl;

int status;
string response;
cout<<\"Detecting device version...\";
//status = IssueCommand(\"?\", \"$%02X\", 100, response);
status = IssueCommand(\"?\", \"V\", 100, response);
cout<<\"In connect status = \"<<status<<endl;
if(status != RQ_SUCCESS)
{
cout<<\"failed (issue ?V response: \"<<status<<\").\"<<endl;
Disconnect();
return RQ_UNRECOGNIZED_DEVICE;
}

if(response.length() > 0)
cout<<\"Voltage is \"<<response<<endl;
if(response.length() < 12)
{
cout<<\"failed (unrecognized version).\"<<endl;
Disconnect();
return RQ_UNRECOGNIZED_VERSION;
}

cout<<response.substr(8, 4)<<\".\"<<endl;
return RQ_SUCCESS;

Program output:
It is able to send 3bytes, but not receiving anything from the controller. The receive status returned is:RQ_ERR_SERIAL_IO


Pls help me out in the above two problem!!!!!!!!!!!!!!!!!!!!!!!

Please Log in or Create an account to join the conversation.

8 years 9 months ago #29526145 by roboteq
Replied by roboteq on topic Re:AX500 RS232 issue in Ubuntu linux
The continous string is normal. In Analog and RC mode, the controller continuously sends a telemetry data string.

You need to switch to serial mode.

To do this, you can either use the default setting and then 5 x Cariage Return characters (0x0d), or you can use the PC utility to configure the controller in serial mode.

Please Log in or Create an account to join the conversation.

8 years 9 months ago #29526147 by rajkum
Thanks a lot! Now I am able to communicate to the controller correctly from linux minicom, after changing it to RS232 mode.
But still not able to communicate with the controller from my program.
Do you have any sample program(or any code snippet) in linux for communicating with the controller via RS232?

thanks,
-Rajesh

Please Log in or Create an account to join the conversation.

Moderators: tonysantoni
Time to create page: 0.162 seconds