Go to Post ...when the rack starts swaying you start praying! - Wayne C. [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 01-02-2013, 19:32
9072997 9072997 is offline
Registered User
FRC #3608 (LISA Jaguars)
Team Role: Programmer
 
Join Date: Feb 2013
Rookie Year: 2011
Location: Arkansas
Posts: 4
9072997 is an unknown quantity at this point
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
on each line with 000 representing the distance (up to 255). When connected to the robot though we get a very different result. Below is part of the code we are using:
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();
        }
    }
the resulting hex dump is:
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
Which (acording to http://www.dolcevie.com/js/converter.html) translates to this:
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????????
Any ideas? Thanks in advance.
Reply With Quote
 


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 08:27.

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