void *Lib_Motor(void *Arg) { int Uart_Handle_Ptr; THREAD_OBJ *pArg = (THREAD_OBJ *)Arg; //-- 시리얼 통신 초기화 Uart_Handle_Ptr = Uart_Open( COM_USB1, BAUD_115200 ); if( Uart_Handle_Ptr < 0 ) { printf("Uart Open Failed \n"); pArg->Thread_Ret = 1; return (void *)&(pArg->Thread_Ret); } Uart_Sig_Init( Uart_Handle_Ptr ); Uart_Sig_Func_Init( Uart_Handle_Ptr, Uart_Rxd_Func ); printf("Enter Motor Thread \n"); while(pArg->Thread_Stop == FALSE) { if( Lib_Motor_Debug == 1 ) { printf("Pwm %d %d bin:%d red:%d Cnt:%03d \n", Lib_Motor_PwmLeft, Lib_Motor_PwmRight, Thre_Bin, Thre_Red, DetectCount ); } if( Lib_Motor_Enable == 1 ) { Uart_Printf( "move pwm %d %d \n", Lib_Motor_PwmLeft, Lib_Motor_PwmRight); } else { Uart_Printf( "move pwm 0 0\n" ); } usleep(100*1000); } printf("Exit Motor Thread \n"); Uart_Printf( "move pwm 0 0\n" ); return (void *)&(pArg->Thread_Ret); }
int32_t irobotUARTOpen( const irobotUARTPort_t port, const irobotBaud_t baud ){ int32_t status = ERROR_SUCCESS; uint32_t baudRate = 0; irobot_StatusMerge(&status, irobotUARTBaudCodeToRate(baud, &baudRate)); if(!irobot_IsError(status)){ irobot_StatusMerge( &status, Uart_Open( port, baudRate, 8, Uart_StopBits1_0, Uart_ParityNone ) ); } return status; }