Connection problem via UART

Frequent questions asked online, offline, in forums are answered here
Post Reply
Soonkyum
Posts: 3
Joined: Wed Jun 10, 2020 9:28 am

Connection problem via UART

Post by Soonkyum »

I am trying to get position data from two hedges.

I set up map with 4 beacons and add two hedges and it works fine on windows.

I connected the hedges to my ubuntu laptop and tried to get position data via UART.

However, I cannot find the devices at /dev and lsusb.

I should have /dev/ttyACM0 and /dev/ttyACM1 but nothing.

I attach the screenshot and the setting of my hedge.

Should I set up hedge in some other way?

Or do I need any additional drivers?

Thanks.
Attachments
Hedge9.PNG
Screenshot 2020-06-10 15_01_31.png

smoker77
Posts: 322
Joined: Sat Feb 06, 2016 4:03 pm

Re: Connection problem via UART

Post by smoker77 »

Hello,

1. If you connect via real UART on the mobile beacon, do you use any UART to USB converter for connection to PC?
2. If you use virtual UART over USB (direct USB connection of hedge to PC), try execute reset of the hedge after connection.
It can be done by hardware reset button on the beacon or software 'reset' button in dashboard when this beacon is selected.
This may be needed because if you connect working hedge via USB when map is frozen and 'power save' option is enabled, hedge can drop down USB port if it is not in use.

In most of Linux distributions no additional drivers are required.
I heard only one exclusion with some single-board computer or PLC.

Soonkyum
Posts: 3
Joined: Wed Jun 10, 2020 9:28 am

Re: Connection problem via UART

Post by Soonkyum »

I am using virtual UART.

I changed the setting not to use power saving and reset several times.

I can find the serial port at /dev/ttyACM0 but cannot open it.

0 d�
Error: unable to open serial connection (possibly serial port is not available)

Having error like above.

Soonkyum
Posts: 3
Joined: Wed Jun 10, 2020 9:28 am

Re: Connection problem via UART

Post by Soonkyum »

I found the problem.

I used the code of

ros::NodeHandle n;
// get port name from command line arguments (if specified)
char ttyFileName[32];

// Init
hedge = createMarvelmindHedge ();
if (hedge==NULL)
{
ROS_INFO ("Error: Unable to create MarvelmindHedge");
return -1;
}
std::string port_name;
if( dir == HEDGE_LEFT )
{
if( !n.getParam("uart_port_left", port_name) )
ROS_ERROR("Failed to find name of uart_port_left.");
}
else if( dir == HEDGE_RIGHT )
{
if( !n.getParam("uart_port_right", port_name) )
ROS_ERROR("Failed to find name of uart_port_right.");
}
sprintf(ttyFileName,"%s", port_name.c_str());
hedge->ttyFileName=ttyFileName;
hedge->verbose=true; // show errors and warnings
hedge->anyInputPacketCallback= semCallback;
startMarvelmindHedge(hedge);

However, I changed

hedge->ttyFileName=ttyFileName;

to

hedge->ttyFileName="/dev/ttyACM0";

It works. I have no idea why the above code is not working.

smoker77
Posts: 322
Joined: Sat Feb 06, 2016 4:03 pm

Re: Connection problem via UART

Post by smoker77 »

Hello,

This code looks like some modification of our ROS node.
It takes serial port name from ROS parameters instead command line parameters as in our node.
May be something occurs with serial port name when it passes through ROS parameters API.

Post Reply