Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00037
00038
00039
00040
00041 #include <iostream>
00042 #include <ecl/command_line.hpp>
00043 #include "kobuki_ftdi/writer.hpp"
00044 #include "kobuki_ftdi/scanner.hpp"
00045
00046
00047
00048
00049
00050 using ecl::CmdLine;
00051 using ecl::UnlabeledValueArg;
00052 using ecl::ValueArg;
00053 using ecl::SwitchArg;
00054 using std::string;
00055
00056
00057
00058
00059
00060 int main(int argc, char **argv)
00061 {
00062
00063
00064
00065 CmdLine cmd_line("This is used to write a new serial id string to the ftdi device.", ' ', "0.1");
00066 ValueArg<std::string> old_arg(
00067 "o", "old", "Identify the device via the old serial id (if there are multiple devices attached) ['unspecified'].", false,
00068 "unspecified", "string");
00069 UnlabeledValueArg<std::string> new_arg("new_id", "New serial id used to identify the device [xxx].", true,
00070 "xxx", "string");
00071 cmd_line.add(old_arg);
00072 cmd_line.add(new_arg);
00073 cmd_line.parse(argc, argv);
00074 bool using_old_id = false;
00075 string old_id;
00076 if (old_arg.getValue() != "unspecified")
00077 {
00078 using_old_id = true;
00079 old_id = old_arg.getValue();
00080 }
00081 string new_id = new_arg.getValue();
00082
00083
00084
00085
00086
00087 std::cout << "Input Information" << std::endl;
00088 if (!using_old_id)
00089 {
00090 std::cout << " Old id: unused (first device found.)" << std::endl;
00091 }
00092 else
00093 {
00094 std::cout << " Old id: " << old_id << std::endl;
00095 }
00096 std::cout << " New id: " << new_id << std::endl;
00097
00098
00099
00100
00101
00102 FTDI_Writer writer;
00103 int ret_val = 0;
00104 ret_val = writer.write(new_id);
00105 if (ret_val<0) {
00106 std::cerr << "Something went wrong." << std::endl;
00107 return ret_val;
00108 }
00109
00110 FTDI_Scanner scanner;
00111 ret_val = scanner.reset();
00112 if (ret_val<0 && ret_val !=-19) {
00113 std::cerr << "Something went wrong." << std::endl;
00114 return ret_val;
00115 }
00116
00117 std::cout << "ret_val: " << ret_val << std::endl;
00118 return 0;
00119 }
00120