Index: trunk/desktop/ICSSerialPort.rbbas
===================================================================
--- trunk/desktop/ICSSerialPort.rbbas	(revision 37)
+++ trunk/desktop/ICSSerialPort.rbbas	(revision 42)
@@ -565,12 +565,19 @@
 	#tag Method, Flags = &h0
 		Sub readCar()
-		  //Read values from the currently attached car
-		  dim sendstring as string
-		  
-		  mode = "read"
-		  
-		  sendstring = chrb(&hC5)
-		  
-		  me.Write(sendstring)
+		  dim portstatus as boolean
+		  //Reopen the port just in case communication was interrupted previously
+		  //This will return true if the port is opened
+		  portstatus = reOpenPort
+		  
+		  if portstatus = true then
+		    //Read values from the currently attached car
+		    dim sendstring as string
+		    
+		    mode = "read"
+		    
+		    sendstring = chrb(&hC5)
+		    
+		    me.Write(sendstring)
+		  end if
 		End Sub
 	#tag EndMethod
@@ -725,15 +732,42 @@
 	#tag Method, Flags = &h0
 		Sub writeCar()
-		  //Send set bytes to the car
-		  mode = "write"
-		  
-		  dim sendstring as string
-		  
-		  calculateChecksum()
-		  
-		  sendstring = byte01 + byte02 + byte03 + byte04 + byte05 + byte06 + byte07 + byte08 + byte09 + byte10 + byte11 + byte12 + byte13 + byte14 + byte15 + byte16 + byte17 + byte18
-		  
-		  me.Write(sendstring)
-		End Sub
+		  dim portstatus as boolean
+		  //Reopen the port just in case communication was interrupted previously
+		  //This will return true if the port is opened
+		  portstatus = reOpenPort
+		  
+		  if portstatus = true then
+		    
+		    //Send set bytes to the car
+		    mode = "write"
+		    
+		    dim sendstring as string
+		    
+		    calculateChecksum()
+		    
+		    sendstring = byte01 + byte02 + byte03 + byte04 + byte05 + byte06 + byte07 + byte08 + byte09 + byte10 + byte11 + byte12 + byte13 + byte14 + byte15 + byte16 + byte17 + byte18
+		    
+		    me.Write(sendstring)
+		    
+		  end if
+		End Sub
+	#tag EndMethod
+
+	#tag Method, Flags = &h21
+		Private Function reOpenPort() As Boolean
+		  dim status as boolean
+		  //Set the return code to false unless the port successfully opens
+		  status = false
+		  
+		  //First close the port just in case
+		  me.Close
+		  
+		  if not me.Open then
+		    //Could not open
+		    MsgBox "Error opening defined com port"
+		  else
+		    status = true
+		  end if
+		End Function
 	#tag EndMethod
 
