diff --git a/lib/App/common/hardwareResourceSerialProvider.cpp b/lib/App/common/hardwareResourceSerialProvider.cpp index af6d09bb..aa6fc45a 100644 --- a/lib/App/common/hardwareResourceSerialProvider.cpp +++ b/lib/App/common/hardwareResourceSerialProvider.cpp @@ -456,11 +456,34 @@ bool hardwareResourceSerialProvider::create_HW(){ #endif m_bManualRTS = false; }; - #else - #ifdef DEBUG - LOG("NO MANUAL RTS CTL"); + #else + #ifdef USE_WIRINGX + if( strstr( m_sUartData.path, "USB" ) == NULL ){ + #ifdef DEBUG + LOG("MANUAL RTS CTL"); + #endif + if( wiringXSetup( WIRINGX_PLATFORM, NULL ) == -1 ){ + LOG_ERROR( "WiringX Platform Init Failure!" ); + m_bManualRTS = false; + } else { + //Set RTS Pin + //pinMode( 0, OUTPUT ); + pinMode( 0, PINMODE_OUTPUT); + m_bManualRTS = true; + }; + } else { + #ifdef DEBUG + LOG("NO MANUAL RTS CTL"); + #endif + m_bManualRTS = false; + }; + + #else + #ifdef DEBUG + LOG("NO MANUAL RTS CTL"); + #endif + m_bManualRTS = false; #endif - m_bManualRTS = false; #endif do{ @@ -1174,7 +1197,7 @@ int hardwareResourceSerialProvider::recptBlock( unsigned char *Buffer, int *Buff }; void hardwareResourceSerialProvider::setRTS( uint8_t Val ){ - #ifdef USE_WIRINGPI + #if defined( USE_WIRINGPI ) || defined( USE_WIRINGX ) if ( Val ) { //Use RTS GPIO digitalWrite( 0, HIGH ); @@ -1198,7 +1221,7 @@ int hardwareResourceSerialProvider::sendBlock(unsigned char* Data, int DataSize) #ifdef __linux__ // setRTS( 1 ); do{ - #ifdef USE_WIRINGPI + #if defined( USE_WIRINGPI ) || defined( USE_WIRINGX ) if( m_bManualRTS ) digitalWrite( 0, HIGH ); #endif RetVal = write( m_iOutFID, Data, DataSize); @@ -1207,7 +1230,7 @@ int hardwareResourceSerialProvider::sendBlock(unsigned char* Data, int DataSize) do { int r = ioctl( m_iOutFID, TIOCSERGETLSR, &lsr ); } while (!(lsr & TIOCSER_TEMT)); - #ifdef USE_WIRINGPI + #ifdef defined( USE_WIRINGPI ) || defined( USE_WIRINGX ) digitalWrite( 0, LOW); #endif }; diff --git a/lib/App/common/hardwareResourceSerialProvider.h b/lib/App/common/hardwareResourceSerialProvider.h index dffbce99..a2152330 100644 --- a/lib/App/common/hardwareResourceSerialProvider.h +++ b/lib/App/common/hardwareResourceSerialProvider.h @@ -26,6 +26,7 @@ //#define USE_WIRINGPI //#include #define USE_WIRINGX + #define WIRINGX_PLATFORM "rock4" #include #endif #endif