try to dedect indexoutof range
This commit is contained in:
parent
d2133c60cd
commit
6ba759751d
55
DuinoDCX.sln
55
DuinoDCX.sln
@ -1,55 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio Version 16
|
|
||||||
VisualStudioVersion = 16.0.31112.23
|
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DuinoDCX", "DuinoDCX\DuinoDCX.csproj", "{455C59F4-F7BB-4D86-AA69-5704118A805D}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bot-Utils", "..\Utils\Bot-Utils\Bot-Utils\Bot-Utils.csproj", "{55EF436B-D16C-49A4-B0E9-BD247E1C6710}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Utils", "..\Utils\Utils\Utils\Utils.csproj", "{56778709-9E18-4C8B-A44B-AB442AFC31B7}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Utils-IoT", "..\Utils\Utils-IoT\Utils-IoT\Utils-IoT.csproj", "{728F2CFC-B0B4-42AB-AD4E-F40905B2D461}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "litjson", "..\Librarys\litjson\litjson\litjson.csproj", "{C67DC10E-9879-44A6-AD1D-AA29EB13E7F0}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DuinoDCXBot", "..\DuinoDCXBot\DuinoDCXBot.csproj", "{5E8700CE-FC44-4574-ACD4-5958AD35ECD3}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|Any CPU = Debug|Any CPU
|
|
||||||
Release|Any CPU = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{455C59F4-F7BB-4D86-AA69-5704118A805D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{455C59F4-F7BB-4D86-AA69-5704118A805D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{455C59F4-F7BB-4D86-AA69-5704118A805D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{455C59F4-F7BB-4D86-AA69-5704118A805D}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{55EF436B-D16C-49A4-B0E9-BD247E1C6710}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{55EF436B-D16C-49A4-B0E9-BD247E1C6710}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{55EF436B-D16C-49A4-B0E9-BD247E1C6710}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{55EF436B-D16C-49A4-B0E9-BD247E1C6710}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{56778709-9E18-4C8B-A44B-AB442AFC31B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{56778709-9E18-4C8B-A44B-AB442AFC31B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{56778709-9E18-4C8B-A44B-AB442AFC31B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{56778709-9E18-4C8B-A44B-AB442AFC31B7}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{728F2CFC-B0B4-42AB-AD4E-F40905B2D461}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{728F2CFC-B0B4-42AB-AD4E-F40905B2D461}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{728F2CFC-B0B4-42AB-AD4E-F40905B2D461}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{728F2CFC-B0B4-42AB-AD4E-F40905B2D461}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{C67DC10E-9879-44A6-AD1D-AA29EB13E7F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{C67DC10E-9879-44A6-AD1D-AA29EB13E7F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{C67DC10E-9879-44A6-AD1D-AA29EB13E7F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{C67DC10E-9879-44A6-AD1D-AA29EB13E7F0}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{5E8700CE-FC44-4574-ACD4-5958AD35ECD3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{5E8700CE-FC44-4574-ACD4-5958AD35ECD3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{5E8700CE-FC44-4574-ACD4-5958AD35ECD3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{5E8700CE-FC44-4574-ACD4-5958AD35ECD3}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
|
||||||
SolutionGuid = {9B9D918F-9E81-490B-A3D1-BA9F10677A7A}
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
@ -18,10 +18,6 @@
|
|||||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="System.IO.Ports" Version="5.0.1" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\LICENSE">
|
<None Include="..\LICENSE">
|
||||||
<Pack>True</Pack>
|
<Pack>True</Pack>
|
||||||
@ -34,5 +30,11 @@
|
|||||||
<Content Include="../LICENSE" />
|
<Content Include="../LICENSE" />
|
||||||
<Content Include="../README.md" />
|
<Content Include="../README.md" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="System.IO.Ports" Version="5.0.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\Utils\Utils\Utils\Utils.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
using System.IO.Ports;
|
using System.IO.Ports;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
|
using BlubbFish.Utils;
|
||||||
|
|
||||||
namespace BlubbFish.IoT.DuinoDCX {
|
namespace BlubbFish.IoT.DuinoDCX {
|
||||||
public class Ultradrive {
|
public class Ultradrive {
|
||||||
private const Int32 MAX_DEVICES = 16;
|
private const Int32 MAX_DEVICES = 16;
|
||||||
@ -81,7 +83,12 @@ namespace BlubbFish.IoT.DuinoDCX {
|
|||||||
|
|
||||||
public void ProcessIncoming(DateTime now) {
|
public void ProcessIncoming(DateTime now) {
|
||||||
while(this.serial.BytesToRead > 0) {
|
while(this.serial.BytesToRead > 0) {
|
||||||
this.ReadCommands(now);
|
try {
|
||||||
|
|
||||||
|
this.ReadCommands();
|
||||||
|
}catch(Exception e) {
|
||||||
|
Helper.WriteError("Error \"" + e.Message + "\" in: " + e.StackTrace);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.isFirstRun) {
|
if(this.isFirstRun) {
|
||||||
@ -164,10 +171,10 @@ namespace BlubbFish.IoT.DuinoDCX {
|
|||||||
Array.Copy(this.dump1, 0, ret, PART_0_LENGTH, PART_1_LENGTH);
|
Array.Copy(this.dump1, 0, ret, PART_0_LENGTH, PART_1_LENGTH);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
return new Byte[0];
|
return Array.Empty<Byte>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Byte[] WriteDeviceStatus() => (DateTime.Now - this.lastPing).TotalMilliseconds < TIMEOUT_TIME ? this.pingResponse : (new Byte[0]);
|
public Byte[] WriteDeviceStatus() => (DateTime.Now - this.lastPing).TotalMilliseconds < TIMEOUT_TIME ? this.pingResponse : Array.Empty<Byte>();
|
||||||
|
|
||||||
public Byte[] WriteDevices() {
|
public Byte[] WriteDevices() {
|
||||||
DateTime now = DateTime.Now;
|
DateTime now = DateTime.Now;
|
||||||
@ -187,7 +194,7 @@ namespace BlubbFish.IoT.DuinoDCX {
|
|||||||
offset += this.devices[i].response.Length;
|
offset += this.devices[i].response.Length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return total > 0 ? ret : (new Byte[0]);
|
return total > 0 ? ret : Array.Empty<Byte>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetSelected(Byte deviceId) => this.selectedDevice = deviceId;
|
public void SetSelected(Byte deviceId) => this.selectedDevice = deviceId;
|
||||||
@ -225,7 +232,7 @@ namespace BlubbFish.IoT.DuinoDCX {
|
|||||||
this.WriteSerial(dumpCommand, dumpCommand.Length);
|
this.WriteSerial(dumpCommand, dumpCommand.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReadCommands(DateTime now) {
|
private void ReadCommands() {
|
||||||
Int32 serialdata = this.serial.ReadByte();
|
Int32 serialdata = this.serial.ReadByte();
|
||||||
if(serialdata == -1) {
|
if(serialdata == -1) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user