Пример #1
0
void Serial_Close_Port(void)
{
        if(serial_port.IsOpen())
	{
                serial_port.Close();
	}
}
int main(int argc, char** argv)
{
    cout << "opening port" << endl;
    mySerial.Open(PORT);
    mySerial.SetBaudRate(SerialStreamBuf::BAUD_9600);
    mySerial.SetCharSize(SerialStreamBuf::CHAR_SIZE_8);
    cout << "port open" << endl;
    
    ros::init(argc, argv, "serialCommands");
    ros::NodeHandle nh_;
    ros::Subscriber arduino_sub = nh_.subscribe("arduino_commands", 60, arduinoCallback);
    arduino_pub = nh_.advertise<std_msgs::String>("arduino_sensors", 5);
    ros::spin();
    mySerial.Close();
}
Пример #3
0
void serialport_close(const char* sp) {
    /*The arduino must be setup to use the same baud rate*/
    ardu.Close() ;
}