primeiros testes

This commit is contained in:
Diego Freitas 2024-11-19 09:19:42 -03:00
parent 9c42b49363
commit 7b21f50513
16 changed files with 26 additions and 23 deletions

Binary file not shown.

View File

@ -61,7 +61,7 @@ namespace AgroBase.Models
public static int CameraSolo { get; } = 6522;
public static int CameraCaminho { get; } = 6544;
public static int Ethernet_AT { get; } = 8899;
public static int Ethernet_TCP { get; } = 502;
public static int Ethernet_TCP { get; } = 8899;
}
public static class VariaveisEquipamento

View File

@ -105,23 +105,12 @@ namespace AgroBase.Services
continue;
}
await ProcessarDadosRecebidosAsync();
// Aguarda resposta do dispositivo com controle de timeout
bool respondido = false;
using (var cts = new CancellationTokenSource(1000)) // Timeout de 1000 ms
{
try
{
while (!respondido && !cts.Token.IsCancellationRequested)
{
await Task.Delay(100, cts.Token);
respondido = DadosLeitura.Any(x => x.Endereco == Addr && x.Iniciado);
}
}
catch (TaskCanceledException)
{
Console.WriteLine($"Timeout ao aguardar resposta do dispositivo com endereço {Addr}.");
}
}
bool respondido = DadosLeitura.Any(x => x.Endereco == Addr && x.Iniciado);
if (respondido)
{
@ -707,7 +696,9 @@ namespace AgroBase.Services
if (_ethernetService != null && _ethernetService.IsConnected)
{
SerialBuffer_RX = new byte[11];
var resposta = await _ethernetService.ReceiveDataAsync(SerialBuffer_RX.Length);
var resposta = await _ethernetService.ReceiveDataAsync(SerialBuffer_RX.Length, 10000);
Console.WriteLine("resposta: " + resposta?.ToString());
if (resposta != null && resposta.Length > 0 && resposta.Length <= SerialBuffer_RX.Length)
{

View File

@ -736,11 +736,11 @@ namespace AgroBase.Services
{
bool ethernetEncontrado = false;
bool DispBld = await ProcuraDispositivoBLD();
/*bool DispBld = await ProcuraDispositivoBLD();
if (DispBld)
{
ethernetEncontrado = true;
}
}*/
bool DispMks = await ProcuraDispositivoMKS();
if (DispMks)

View File

@ -40,13 +40,13 @@ namespace AgroBase.Services
{
// Enviar "+++"
await SendCommandAsync("+++");
string response = await ReceiveResponseAsync(1000);
string response = await ReceiveResponseAsync(10000);
if (response != "a") return false;
// Enviar "a" para entrar no modo AT
await Task.Delay(300); // Espera curta
await SendCommandAsync("a");
response = await ReceiveResponseAsync(1000);
response = await ReceiveResponseAsync(10000);
return response.Contains("+ok");
}
catch

View File

@ -8735,3 +8735,15 @@
11/11/2024 17:19:33:884 - Porta COM - 2: Timeout ao receber resposta. GET=True, Parametro=1
11/11/2024 17:19:34:743 - Porta COM - 4: Porta serial não está definida
11/11/2024 17:19:35:841 - Porta COM - 4: Timeout ao receber resposta. GET=True, Parametro=1
18/11/2024 16:36:33:118 - Endereço 3 (192.168.0.7): Erro ao enviar dados via Ethernet
18/11/2024 16:36:34:140 - Endereço 2 (192.168.0.7): Conexão Ethernet não está definida ou não está conectada
18/11/2024 16:36:35:171 - Endereço 4 (192.168.0.7): Conexão Ethernet não está definida ou não está conectada
18/11/2024 16:40:20:317 - Endereço 3 (192.168.0.7): Erro ao enviar dados via Ethernet
18/11/2024 16:40:21:329 - Endereço 2 (192.168.0.7): Conexão Ethernet não está definida ou não está conectada
18/11/2024 16:40:22:344 - Endereço 4 (192.168.0.7): Conexão Ethernet não está definida ou não está conectada
18/11/2024 16:58:14:982 - Endereço 1 (192.168.0.7): Erro ao enviar dados via Ethernet
18/11/2024 16:58:16:008 - Endereço 3 (192.168.0.7): Conexão Ethernet não está definida ou não está conectada
18/11/2024 16:58:17:036 - Endereço 2 (192.168.0.7): Conexão Ethernet não está definida ou não está conectada
18/11/2024 16:58:18:060 - Endereço 4 (192.168.0.7): Conexão Ethernet não está definida ou não está conectada
19/11/2024 08:34:53:402 - Endereço 105 (192.168.0.7): Dados recebidos de um endereço inválido: [111 105 18 18 18 18 111 105]
19/11/2024 08:36:18:843 - Endereço 105 (192.168.0.7): Dados recebidos de um endereço inválido: [111 105]

File diff suppressed because one or more lines are too long