]> git.mxchange.org Git - simgear.git/blobdiff - simgear/io/sg_serial.cxx
Fix a build order problem.
[simgear.git] / simgear / io / sg_serial.cxx
index 2d409fb8f92371d3d195138d223d3f1ee457387c..d174bcd203ab74b5f88e75435211cfff071a4e0b 100644 (file)
 FG_USING_STD(string);
 
 
-SGSerial::SGSerial() :
+SGSerial::SGSerial( const string& device_name, const string& baud_rate ) :
     save_len(0)
 {
     set_type( sgSerialType );
+    device = device_name;
+    baud = baud_rate;
 }
 
 
@@ -45,7 +47,9 @@ SGSerial::~SGSerial() {
 
 
 // open the serial port based on specified direction
-bool SGSerial::open( SGProtocolDir dir ) {
+bool SGSerial::open( const SGProtocolDir d ) {
+    set_dir( d );
+
     if ( ! port.open_port( device ) ) {
        FG_LOG( FG_IO, FG_ALERT, "Error opening device: " << device );
        return false;
@@ -125,7 +129,7 @@ int SGSerial::readline( char *buf, int length ) {
 
 
 // write data to port
-int SGSerial::write( char *buf, int length ) {
+int SGSerial::write( const char *buf, const int length ) {
     int result = port.write_port( buf, length );
 
     if ( result != length ) {
@@ -137,7 +141,7 @@ int SGSerial::write( char *buf, int length ) {
 
 
 // write null terminated string to port
-int SGSerial::writestring( char *str ) {
+int SGSerial::writestring( const char *str ) {
     int length = strlen( str );
     return write( str, length );
 }