serial3_arduino_start.cpp
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <string.h>
00004 #include <ros/ros.h>
00005 #include "rs232/rs232.h"
00006 
00007 #define ARDUINO_PORT 0
00008 #define ARDUINO_BAURATE 115200
00009 char mode[]={'8','N','1',0};  // 8bits, No Parity, 2 Stopbits,
00010 
00011 
00012 bool setup_COM_port(){
00013 
00014     // wait 1 second to open port
00015     sleep (1);
00016 
00017     if(RS232_OpenComport(ARDUINO_PORT, ARDUINO_BAURATE, mode))
00018     {
00019         ROS_ERROR("Can not open comport: %d\n", ARDUINO_PORT);
00020         return false;
00021     }
00022 
00023     ROS_INFO("USB port Successfully open %d\n", ARDUINO_PORT);
00024 
00025     // wait 2 seconds for opened port
00026     sleep (2);
00027 
00028     return true;
00029 }
00030 
00031 
00032 int serialWrite(){
00033 
00034     unsigned char send_start_msg[3]={'@',//0x40,  //@
00035                                      '1',//0x31,  //1
00036                                      'e'};//0x65}; //e
00037 
00038     ROS_INFO("Command sent!!! \n");
00039 
00040     RS232_SendBuf(ARDUINO_PORT, send_start_msg, 3);  // Confirm to Spark that is alive too
00041 
00042     return 0;
00043 }
00044 
00045 
00046 int main()
00047 {
00048 
00049     while(!setup_COM_port()){       // Retry every second if port is open
00050         sleep(1);
00051     }
00052 
00053     serialWrite();
00054     
00055     //RS232_CloseComport(ARDUINO_PORT);
00056 
00057     return 0;
00058 }
00059 


forte_rc_driver
Author(s): Ingeniarius, Ltd.
autogenerated on Sat Jun 8 2019 19:54:46