[vb 2005] Erro O período de tempo de espera do semáforo expirou.

paxa

Power Member
Boas.


Tenho andado a testar uma aplicação que utiliza 3 objectos serial port para efectuar a comunicação com 3 leitores de códigos de barras, códigos de barras estes que estão ligados e emparelhados num adaptador bluetooth.
Os problemas acontecem quando ao fim de 1h30, 2 horas fico sem comunicação entre os leitores e o sistema ou ao iniciar a aplicação não tenho comunicação com os leitores e recebo esta mensagem no visualizador de eventos:

Código:
Timestamp: 19-03-2009 21:02:34
Message: There is no explicit mapping for the categories 'Geral'. The log entry was: 
Timestamp: 19-03-2009 21:02:34
Message: ERRO EVENTO LOAD FRMMAIN: O período de tempo de espera do semáforo expirou.
 #    at System.IO.Ports.InternalResources.WinIOError(Int32 errorCode, String str)
   at System.IO.Ports.SerialStream..ctor(String portName, Int32 baudRate, Parity parity, Int32 dataBits, StopBits stopBits, Int32 readTimeout, Int32 writeTimeout, Handshake handshake, Boolean dtrEnable, Boolean rtsEnable, Boolean discardNull, Byte parityReplace)
   at System.IO.Ports.SerialPort.Open()
   at Supervisor.FrmMain.FrmMain_Load(Object sender, EventArgs e)
Category: Geral
Priority: 3
EventId: 0
Severity: Error
Title:
Machine: PCEV1198
App Domain: Supervisor.exe
ProcessId: 1864
Process Name: C:\Program Files\KEMET\SupervisorGlobal\Supervisor.exe
Thread Name: 
Win32 ThreadId:1756
Extended Properties: 
Category: 
Priority: -1
EventId: 6352
Severity: Error
Title:
Machine: PCEV1198
Application Domain: Supervisor.exe
Process Id: 1864
Process Name: C:\Program Files\KEMET\SupervisorGlobal\Supervisor.exe
Win32 Thread Id: 1756
Thread Name: 
Extended Properties:

Tou a usar o seguinte código para testes de comunicação, para que a ligação seja estabelecida:

Código:
Private Sub FrmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
'# porta com 1
SerialPort1.PortName = "COM3"
SerialPort1.BaudRate = 9600
SerialPort1.DataBits = 8
SerialPort1.StopBits = Ports.StopBits.One
SerialPort1.Parity = Ports.Parity.None
SerialPort1.Open()
System.Threading.Thread.Sleep(2000)
'#
'# porta com 2
SerialPort2.PortName = "COM5"
SerialPort2.BaudRate = 9600
SerialPort2.DataBits = 8
SerialPort2.Parity = Ports.Parity.None
SerialPort2.StopBits = Ports.StopBits.One
SerialPort2.Open()
System.Threading.Thread.Sleep(2000)
 '#
 
'# porta com 3
SerialPort3.PortName = "COM7"
SerialPort3.BaudRate = 9600
SerialPort3.Parity = Ports.Parity.None
SerialPort3.DataBits = 8
SerialPort3.StopBits = Ports.StopBits.One
SerialPort3.Open()
System.Threading.Thread.Sleep(2000)
'#
Catch ex as Exception
log("ERRO FRMMAIN:  "+ ex.message+ " # " + ex.StackTrace)
End Try
 
 
end sub

E para tratar os dados utilizo o evento Datarecieved do objecto:

Código:
[SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SerialPort1_DataRecieved([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] System.IO.Ports.SerialDataReceivedEventArgs) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SerialPort1.DataReceived
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] leitor [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = 1
Leitura.Leitura = SerialPort1.ReadExisting
InterpretaComando([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], leitor, Leitura, Generica.Colaborador)
Leitura.Leitura = [/SIZE][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000]""
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Catch[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ex [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Exception
Log([/SIZE][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000]"SerialPort1 error: "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + ex.Message + [/SIZE][SIZE=2][COLOR=#800000][SIZE=2][COLOR=#800000]" # "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + ex.StackTrace)
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Finally
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]SerialPort1.DiscardInBuffer()
SerialPort1.DiscardOutBuffer()
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE][/COLOR][/SIZE]

Andei a efectuar pesquisas sobre isto e não consigo arranjar uma solução para este problema

Agradecia algum tipo de ajuda neste assunto.

Obrigado


 
Back
Topo