[B /ReceiveCmd [P [A timeout] /state FALSE def /respStr '' def /RxBuf 100 Comm.CreateBuffer def RxBuf Comm.ClearBuffer RxBuf timeout 2 Comm.WaitForCount Comm.GetExpired not [B /respStr respStr RxBuf Comm.GetBuffer add def /respSize RxBuf Comm.GetBuffer 1 1 getsubstr ord def RxBuf Comm.ClearBuffer RxBuf timeout respSize 1 add Comm.WaitForCount Comm.GetExpired not [B /respStr respStr RxBuf Comm.GetBuffer add def /state TRUE def ] if ] if % return the state [A respStr state] ] def 'PackInst' import /LogMemo Create:LogMemo def /Log [B LogMemo.Log ] def /LogError [B % font color is set for the whole window, so no reset shall be done $000000FF LogMemo.SetFontColor Log ] def 10 LogMemo.SetFontSize LogMemo.Show % Chose the serial port for the communication with the servo controller PackInst:_SelectCommPort [B /PortType exch def /ComPort exch def % Configure and open the serial port /Comm Create:Comm def ComPort 38400 Comm.Open 'Sending break command and waiting for response from controller...' log /ROSrunning FALSE def /ROSUnknown FALSE def 100 [B $A5 chr $02 chr add $A1 chr add $A0 chr add $01 chr add Comm.SendString 100 ReceiveCmd /RXState exch def /RxMessage exch def RXState [B /RXsize RxMessage length def RXsize 5 ge [B /response RxMessage 4 1 getsubstr ord def response 0 eq [B /ROSrunning TRUE def exitloop ] if response $EC eq [B % command unknown /ROSUnknown TRUE def exitloop ] if ] if ] if ] repeat ROSrunning [B 'ROS successfully started!' log ] [B ROSUnknown [B 'ROS start failed! OS still running or ROS unknown!' LogError ] [B 'ROS start failed! No response from controller!' LogError ] ifelse ] ifelse Comm.Close ] [B 'ROS start aborted! No port has been selected!' LogError ] ifelse LogMemo.Remain ]