|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Trouble With cRIO Serial Port
We would like to add a ultrasonic sensor to our robot and have one that outputs RS-232. So we wired up an old serial cable to the proper pins, and after some work we got output from hyper terminal in the correct format of
Code:
R000 Code:
SerialPort sonarSensor;
public static String bytesToHex(byte[] bytes) {
final char[] hexArray = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
char[] hexChars = new char[bytes.length * 2];
int v;
for ( int j = 0; j < bytes.length; j++ ) {
v = bytes[j] & 0xFF;
hexChars[j * 2] = hexArray[v >>> 4];
hexChars[j * 2 + 1] = hexArray[v & 0x0F];
}
return new String(hexChars);
}
void updateDashboard() {
try {
for(int i = 0 ; sonarSensor.getBytesReceived() > 0 ; i++) {
System.out.println(bytesToHex(sonarSensor.read(20)));
if(i > 100) {
System.out.println("RESET");
sonarSensor.reset();
break;
}
}
System.out.println("DONE");
} catch (Throwable exception) {
exception.printStackTrace();
}
}
Code:
434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 4153524C313A3A494E53545200000001742E6F75 434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 4153524C313A3A494E53545200000001742E6F75 434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 4153524C313A3A494E53545200000001742E6F75 434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 4153524C313A3A494E53545200000001742E6F75 434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 4153524C313A3A494E53545200000001742E6F75 434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 4153524C313A3A494E53545200000001742E6F75 434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 4153524C313A3A494E53545200000001742E6F75 434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 4153524C313A3A494E53545200000001742E6F75 434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 4153524C313A3A494E53545200000001742E6F75 434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 4153524C313A3A494E53545200000001742E6F75 434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 4153524C313A3A494E53545200000001742E6F75 434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 4153524C313A3A494E53545200000001742E6F75 434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 4153524C313A3A494E53545200000001742E6F75 434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 4153524C313A3A494E53545200000001742E6F75 434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 4153524C313A3A494E53545200000001742E6F75 434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 4153524C313A3A494E53545200000001742E6F75 434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 4153524C313A3A494E53545200000001742E6F75 434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 4153524C313A3A494E53545200000001742E6F75 434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 4153524C313A3A494E53545200000001742E6F75 434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 4153524C313A3A494E53545200000001742E6F75 434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 4153524C313A3A494E53545200000001742E6F75 434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 4153524C313A3A494E53545200000001742E6F75 434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 4153524C313A3A494E53545200000001742E6F75 434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 4153524C313A3A494E53545200000001742E6F75 434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 4153524C313A3A494E53545200000001742E6F75 434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 4153524C313A3A494E53545200000001742E6F75 434F4D31202D2000000000050000000155706461 434F4D31202D204275696C742D496E0038210010 Code:
COM1 - ?????????Upda?4??????'V??B????????ASRL1::INSTR????t.ou?4??????????P????W?F?COM1 - Built-In?8!????5$??????5E ????B???COM1 - ?????????Upda?4??????'V??B????????ASRL1::INSTR????t.ou?4??????????P????W?F?COM1 - Built-In?8!????5$??????5E ????B???COM1 - ?????????Upda?4??????'V??B????????ASRL1::INSTR????t.ou?4??????????P????W?F?COM1 - Built-In?8!????5$??????5E ????B???COM1 - ?????????Upda?4??????'V??B????????ASRL1::INSTR????t.ou?4??????????P????W?F?COM1 - Built-In?8!????5$??????5E ????B???COM1 - ?????????Upda?4??????'V??B????????ASRL1::INSTR????t.ou?4??????????P????W?F?COM1 - Built-In?8!????5$??????5E ????B???COM1 - ?????????Upda?4??????'V??B????????ASRL1::INSTR????t.ou?4??????????P????W?F?COM1 - Built-In?8!????5$??????5E ????B???COM1 - ?????????Upda?4??????'V??B????????ASRL1::INSTR????t.ou?4??????????P????W?F?COM1 - Built-In?8!????5$??????5E ????B???COM1 - ?????????Upda?4??????'V??B????????ASRL1::INSTR????t.ou?4??????????P????W?F?COM1 - Built-In?8!????5$??????5E ????B???COM1 - ?????????Upda?4??????'V??B????????ASRL1::INSTR????t.ou?4??????????P????W?F?COM1 - Built-In?8!????5$??????5E ????B???COM1 - ?????????Upda?4??????'V??B????????ASRL1::INSTR????t.ou?4??????????P????W?F?COM1 - Built-In?8!????5$??????5E ????B???COM1 - ?????????Upda?4??????'V??B????????ASRL1::INSTR????t.ou?4??????????P????W?F?COM1 - Built-In?8!????5$??????5E ????B???COM1 - ?????????Upda?4??????'V??B????????ASRL1::INSTR????t.ou?4??????????P????W?F?COM1 - Built-In?8!????5$??????5E ????B???COM1 - ?????????Upda?4??????'V??B????????ASRL1::INSTR????t.ou?4??????????P????W?F?COM1 - Built-In?8!????5$??????5E ????B???COM1 - ?????????Upda?4??????'V??B???????? |
|
#2
|
||||||
|
||||||
|
Re: Trouble With cRIO Serial Port
Is the console out switch turned off? Where is your constructor for the sonarSensor?
|
|
#3
|
|||
|
|||
|
Re: Trouble With cRIO Serial Port
Right now it's:
Code:
sonarSensor = new SerialPort(9600); Code:
sonarSensor = new SerialPort(9600, 8); Code:
sonarSensor = new SerialPort(9600, 7); |
|
#4
|
|||
|
|||
|
Re: Trouble With cRIO Serial Port
For others, It appears as though while my computer was able to accept +/-5V for the serial data line the cRIO may require the full +/-12V defined by RS-232.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|