diff --git a/IoTSharp.Gateway.Modbus.csproj b/IoTSharp.Gateway.Modbus.csproj index df2e324..ccbcb6f 100644 --- a/IoTSharp.Gateway.Modbus.csproj +++ b/IoTSharp.Gateway.Modbus.csproj @@ -2,11 +2,15 @@ net6.0 - enable + annotations enable aspnet-IoTSharp.Gateway.Modbus-554A6128-AB47-40BC-8BC3-40D3123C6BFF Linux . + + https://api.nuget.org/v3/index.json; + https://www.myget.org/F/iotsharp/api/v3/index.json; + @@ -14,19 +18,20 @@ - + + - + diff --git a/Pages/PointMapAdmin/Index.cshtml.cs b/Pages/PointMapAdmin/Index.cshtml.cs index 82d5084..da83283 100644 --- a/Pages/PointMapAdmin/Index.cshtml.cs +++ b/Pages/PointMapAdmin/Index.cshtml.cs @@ -23,7 +23,7 @@ namespace IoTSharp.Gateway.Modbus.Pages.PointMapAdmin public async Task OnGetAsync(Guid id) { SlaveId = id; - if (_context.PointMappings != null && id!=null) + if (_context.PointMappings != null && id!=Guid.Empty) { PointMapping = await _context.PointMappings.Include(pt => pt.Owner).Where(fm => fm.Owner!=null && fm.Owner.Id == id).ToListAsync(); } diff --git a/Program.cs b/Program.cs index 862a33a..a9d9267 100644 --- a/Program.cs +++ b/Program.cs @@ -9,6 +9,7 @@ namespace IoTSharp.Gateway.Modbus { public static void Main(string[] args) { + System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); var builder = WebApplication.CreateBuilder(args); // Add services to the container. var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found."); diff --git a/Services/ModbusMaster.cs b/Services/ModbusMaster.cs index 7deae3c..16eae3e 100644 --- a/Services/ModbusMaster.cs +++ b/Services/ModbusMaster.cs @@ -74,7 +74,7 @@ namespace IoTSharp.Gateway.Modbus.Services } while (!stoppingToken.IsCancellationRequested); } - private async Task ReadDatas(ModbusSlave slave, IModbusClient? client, CancellationToken stoppingToken) + private async Task ReadDatas(ModbusSlave slave, IModbusClient client, CancellationToken stoppingToken) { var points = _dbContext.PointMappings.Include(p => p.Owner).Where(p => p.Owner == slave).ToList(); foreach (var point in points) @@ -259,14 +259,12 @@ namespace IoTSharp.Gateway.Modbus.Services ParseDtuParam(url, dtu); client = dtu; break; - case "tcp": client = new AMWD.Modbus.Tcp.Client.ModbusClient(url.Host, url.Port, mlog); break; - case "d2t": - // client = new AMWD.Modbus.Tcp.Client.ModbusClient(url.Host, url.Port, mlog); - + client = new AMWD.Modbus.SerialOverTCP.Client.ModbusClient(url.Host, url.Port, mlog); + break; default: break; }