[B
  'PackInst' import  
 
  /LogMemo Create:LogMemo def
  /Log [B LogMemo.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    
    PortType 'CAN' eq [B
     	%PackInst:_SelectDeviceMACID [B  
     		%/DeviceMACID exch def	
      %] if
    ]
    [B
      % Configure and open the serial port
      /Comm Create:Comm def
      ComPort 38400 Comm.Open
      % Create a buffer for receive the data
      /RxBuf 100 Comm.CreateBuffer def
      RxBuf Comm.ClearBuffer
      100 wait
      'Sending stop command and waiting for response from controller...' log      
      /NumOfAttemps 0 def
      20 [B
        /NumOfAttemps NumOfAttemps 1 add def
        $A5 chr $01 chr add $21 chr add $21 chr add Comm.SendString
        RxBuf 500 $A5 chr Comm.WaitForChar
        Comm.GetExpired not [B ExitLoop ] if
      ] repeat
      NumOfAttemps 20 lt [B
        'Firmware successfully stopped!' log
      ]
      [B
        'Firmware stop: failed! No response from controller!' log      
      ] ifelse  
      Comm.Close
    ] ifelse  
  ]
  [B
    'Firmware stop: aborted! No port has been selected!' log  
  ] ifelse
             
  LogMemo.Remain  
]