Go to Post Unsure if I'll get it to work, but that's no reason to not try. - DonRotolo [more]
Home
Go Back   Chief Delphi > Technical > Electrical
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 30-01-2016, 13:26
The Doctor's Avatar
The Doctor The Doctor is offline
Robotics is life
AKA: Hackson
FRC #3216 (MR. T)
Team Role: Programmer
 
Join Date: Mar 2014
Rookie Year: 2013
Location: United States
Posts: 150
The Doctor is on a distinguished road
Roborio comms with arduino over USB

Recently I've been experimenting with sending status codes to an Arduino from the RoboRio. I've so far tried toggling serial from the MXP to the arduino, and serial over USB between them. Neither of these have worked yet. I was wondering if any teams had input on how to send single byte status packets?

Current robot code (java):

Code:
arduino = new SerialPort(19200,SerialPort.Port.kUSB);
...
byte mode1 = 0;  //////// 0b<red><blue><fms><auton><teleop><disabled><enabled><attached>
				if (ds.getAlliance() == DriverStation.Alliance.Red)  mode1 |= 0b10000000;
				if (ds.getAlliance() == DriverStation.Alliance.Blue) mode1 |= 0b01000000;
				if (ds.isFMSAttached())                              mode1 |= 0b00100000;
				if (ds.isAutonomous())                               mode1 |= 0b00010000;
				if (ds.isOperatorControl())                          mode1 |= 0b00001000;
				if (ds.isDisabled())                                 mode1 |= 0b00000100;
				if (ds.isEnabled())                                  mode1 |= 0b00000010;
				if (ds.isDSAttached())                               mode1 |= 0b00000001;
				
				byte[] mode2 = {mode1};
				arduino.write(mode2, 1);
The problem is that the instantiation of the SerialPort object causes the robot code to error and restart. The exact error can't be copied out of the DS, but it's something along the lines of this:

Code:
RuntimeException: HAL: -VISA: Resource not found at [SerialPortJNI.serialInitializePort]
Has anyone gotten Rio-to-Arduino comms to work using Serial?
__________________
Robots + Python + pentesting == me;
Blog ~ GitHub ~ Keybase
If you have a pressing issue to discuss with me, kik me at slush.puddles since I don't check CD very often.
  #2   Spotlight this post!  
Unread 30-01-2016, 13:48
RyanN's Avatar
RyanN RyanN is offline
RyanN
AKA: Ryan Nazaretian
FRC #4901 (Garnet Squadron)
Team Role: Mentor
 
Join Date: Jun 2006
Rookie Year: 2005
Location: Columbia, SC
Posts: 1,126
RyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond repute
Re: Roborio comms with arduino over USB

Quote:
Originally Posted by The Doctor View Post
Recently I've been experimenting with sending status codes to an Arduino from the RoboRio. I've so far tried toggling serial from the MXP to the arduino, and serial over USB between them. Neither of these have worked yet. I was wondering if any teams had input on how to send single byte status packets?

Current robot code (java):

Code:
arduino = new SerialPort(19200,SerialPort.Port.kUSB);
...
byte mode1 = 0;  //////// 0b<red><blue><fms><auton><teleop><disabled><enabled><attached>
				if (ds.getAlliance() == DriverStation.Alliance.Red)  mode1 |= 0b10000000;
				if (ds.getAlliance() == DriverStation.Alliance.Blue) mode1 |= 0b01000000;
				if (ds.isFMSAttached())                              mode1 |= 0b00100000;
				if (ds.isAutonomous())                               mode1 |= 0b00010000;
				if (ds.isOperatorControl())                          mode1 |= 0b00001000;
				if (ds.isDisabled())                                 mode1 |= 0b00000100;
				if (ds.isEnabled())                                  mode1 |= 0b00000010;
				if (ds.isDSAttached())                               mode1 |= 0b00000001;
				
				byte[] mode2 = {mode1};
				arduino.write(mode2, 1);
The problem is that the instantiation of the SerialPort object causes the robot code to error and restart. The exact error can't be copied out of the DS, but it's something along the lines of this:

Code:
RuntimeException: HAL: -VISA: Resource not found at [SerialPortJNI.serialInitializePort]
Has anyone gotten Rio-to-Arduino comms to work using Serial?
I got it working. I never tried an Uno or Mega, but the Pro with the FTDI USB to Serial does work. The Uno or Mega might work, but the Uno clone using a CH340 or CH341 USB to Serial did not work.
__________________
Garnet Squadron
FRC 4901
Controls Mentor
@rnazaretian

Previous mentor and student from Team Fusion, FRC 364
  #3   Spotlight this post!  
Unread 31-01-2016, 22:58
mikhail's Avatar
mikhail mikhail is offline
Registered User
AKA: Mentor of The Software ERRORs
FRC #3130 (ERRORS)
Team Role: Mentor
 
Join Date: Dec 2014
Rookie Year: 2013
Location: Minnesota
Posts: 17
mikhail is an unknown quantity at this point
Re: Roborio comms with arduino over USB

How do you guys specify which USB port of the RoboRIO to use? We have a webcam and an Arduino board plugged into the two RoboRIO ports. I can be wrong but it seems that the robot code tries to talk to a wrong device sometimes. Can I do something more specific than kUSB? Thanks.
  #4   Spotlight this post!  
Unread 01-02-2016, 07:43
RyanN's Avatar
RyanN RyanN is offline
RyanN
AKA: Ryan Nazaretian
FRC #4901 (Garnet Squadron)
Team Role: Mentor
 
Join Date: Jun 2006
Rookie Year: 2005
Location: Columbia, SC
Posts: 1,126
RyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond repute
Re: Roborio comms with arduino over USB

Quote:
Originally Posted by mikhail View Post
How do you guys specify which USB port of the RoboRIO to use? We have a webcam and an Arduino board plugged into the two RoboRIO ports. I can be wrong but it seems that the robot code tries to talk to a wrong device sometimes. Can I do something more specific than kUSB? Thanks.
LabVIEW enumerates the ports for me. I guess since it's running Linux that you can find the port under/dev/ttyUSB0 or something similar.
__________________
Garnet Squadron
FRC 4901
Controls Mentor
@rnazaretian

Previous mentor and student from Team Fusion, FRC 364
  #5   Spotlight this post!  
Unread 10-02-2016, 22:00
Justin Buist Justin Buist is offline
Registered User
FRC #4003 (TriSonics)
Team Role: Mentor
 
Join Date: Feb 2015
Rookie Year: 2015
Location: Allendale, MI
Posts: 18
Justin Buist is an unknown quantity at this point
Re: Roborio comms with arduino over USB

USB doesn't really have "ports." The two ports on the roboRIO are basically the same hole, if you will, much like putting a USB hub into one doesn't make 6 new addressable spaces, it's just more holes on the bus.

Your Arduino will show up as /dev/ttyUSB0 or /dev/ttyACM0 in some cases, like a Mega.

The webcam will show up as /dev/video0, then /dev/video1, etc, as you add cameras assuming they're supported in Video4Linux.

The addressing is basically the responsibility of the OS unless you want to get far deeper into USB specs than I have ever bothered.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 02:35.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi