primeiros testes
This commit is contained in:
parent
9c42b49363
commit
7b21f50513
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -61,7 +61,7 @@ namespace AgroBase.Models
|
||||||
public static int CameraSolo { get; } = 6522;
|
public static int CameraSolo { get; } = 6522;
|
||||||
public static int CameraCaminho { get; } = 6544;
|
public static int CameraCaminho { get; } = 6544;
|
||||||
public static int Ethernet_AT { get; } = 8899;
|
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
|
public static class VariaveisEquipamento
|
||||||
|
|
|
||||||
|
|
@ -105,23 +105,12 @@ namespace AgroBase.Services
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
await ProcessarDadosRecebidosAsync();
|
||||||
|
|
||||||
|
|
||||||
// Aguarda resposta do dispositivo com controle de timeout
|
// Aguarda resposta do dispositivo com controle de timeout
|
||||||
bool respondido = false;
|
bool respondido = DadosLeitura.Any(x => x.Endereco == Addr && x.Iniciado);
|
||||||
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}.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (respondido)
|
if (respondido)
|
||||||
{
|
{
|
||||||
|
|
@ -707,7 +696,9 @@ namespace AgroBase.Services
|
||||||
if (_ethernetService != null && _ethernetService.IsConnected)
|
if (_ethernetService != null && _ethernetService.IsConnected)
|
||||||
{
|
{
|
||||||
SerialBuffer_RX = new byte[11];
|
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)
|
if (resposta != null && resposta.Length > 0 && resposta.Length <= SerialBuffer_RX.Length)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -736,11 +736,11 @@ namespace AgroBase.Services
|
||||||
{
|
{
|
||||||
bool ethernetEncontrado = false;
|
bool ethernetEncontrado = false;
|
||||||
|
|
||||||
bool DispBld = await ProcuraDispositivoBLD();
|
/*bool DispBld = await ProcuraDispositivoBLD();
|
||||||
if (DispBld)
|
if (DispBld)
|
||||||
{
|
{
|
||||||
ethernetEncontrado = true;
|
ethernetEncontrado = true;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
bool DispMks = await ProcuraDispositivoMKS();
|
bool DispMks = await ProcuraDispositivoMKS();
|
||||||
if (DispMks)
|
if (DispMks)
|
||||||
|
|
|
||||||
|
|
@ -40,13 +40,13 @@ namespace AgroBase.Services
|
||||||
{
|
{
|
||||||
// Enviar "+++"
|
// Enviar "+++"
|
||||||
await SendCommandAsync("+++");
|
await SendCommandAsync("+++");
|
||||||
string response = await ReceiveResponseAsync(1000);
|
string response = await ReceiveResponseAsync(10000);
|
||||||
if (response != "a") return false;
|
if (response != "a") return false;
|
||||||
|
|
||||||
// Enviar "a" para entrar no modo AT
|
// Enviar "a" para entrar no modo AT
|
||||||
await Task.Delay(300); // Espera curta
|
await Task.Delay(300); // Espera curta
|
||||||
await SendCommandAsync("a");
|
await SendCommandAsync("a");
|
||||||
response = await ReceiveResponseAsync(1000);
|
response = await ReceiveResponseAsync(10000);
|
||||||
return response.Contains("+ok");
|
return response.Contains("+ok");
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -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: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: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
|
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue