Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Commit

Permalink
fix: handle multi value registers
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Jan 7, 2022
1 parent 756e097 commit 7649bd8
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 17 deletions.
9 changes: 7 additions & 2 deletions Jacdac/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,15 @@ protected object GetRegisterValue(ushort code, string packFormat)
return this.GetRegisterValues(code, packFormat)[0];
}

protected void SetRegisterValue(ushort code, string packetFormat, object value)
protected void SetRegisterValues(ushort code, string packetFormat, object[] values)
{
var reg = this.WaitForRegister(code);
reg.SendValues(new object[] { value });
reg.SendValues(values);
}

protected void SetRegisterValue(ushort code, string packetFormat, object value)
{
this.SetRegisterValues(code, packetFormat, new object[] { value });
}

protected void SendCmd(ushort code, byte[] data = null)
Expand Down
2 changes: 1 addition & 1 deletion Jacdac/Clients/AccelerometerClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public AccelerometerClient(JDBus bus, string name)
{
get
{
return (object[] /*(float, float, float)*/)this.GetRegisterValue((ushort)AccelerometerReg.Forces, AccelerometerRegPack.Forces);
return (object[] /*(float, float, float)*/)this.GetRegisterValues((ushort)AccelerometerReg.Forces, AccelerometerRegPack.Forces);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Jacdac/Clients/ColorClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public ColorClient(JDBus bus, string name)
{
get
{
return (object[] /*(float, float, float)*/)this.GetRegisterValue((ushort)ColorReg.Color, ColorRegPack.Color);
return (object[] /*(float, float, float)*/)this.GetRegisterValues((ushort)ColorReg.Color, ColorRegPack.Color);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Jacdac/Clients/GamepadClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public GamepadClient(JDBus bus, string name)
{
get
{
return (object[] /*(GamepadButtons, float, float)*/)this.GetRegisterValue((ushort)GamepadReg.Direction, GamepadRegPack.Direction);
return (object[] /*(GamepadButtons, float, float)*/)this.GetRegisterValues((ushort)GamepadReg.Direction, GamepadRegPack.Direction);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Jacdac/Clients/GyroscopeClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public GyroscopeClient(JDBus bus, string name)
{
get
{
return (object[] /*(float, float, float)*/)this.GetRegisterValue((ushort)GyroscopeReg.RotationRates, GyroscopeRegPack.RotationRates);
return (object[] /*(float, float, float)*/)this.GetRegisterValues((ushort)GyroscopeReg.RotationRates, GyroscopeRegPack.RotationRates);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Jacdac/Clients/LedClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public LedClient(JDBus bus, string name)
{
get
{
return (object[] /*(uint, uint, uint)*/)this.GetRegisterValue((ushort)LedReg.Color, LedRegPack.Color);
return (object[] /*(uint, uint, uint)*/)this.GetRegisterValues((ushort)LedReg.Color, LedRegPack.Color);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Jacdac/Clients/MagnetometerClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public MagnetometerClient(JDBus bus, string name)
{
get
{
return (object[] /*(int, int, int)*/)this.GetRegisterValue((ushort)MagnetometerReg.Forces, MagnetometerRegPack.Forces);
return (object[] /*(int, int, int)*/)this.GetRegisterValues((ushort)MagnetometerReg.Forces, MagnetometerRegPack.Forces);
}
}

Expand Down
12 changes: 6 additions & 6 deletions Jacdac/Clients/ProtoTestClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,12 @@ public byte[] RoBytes
{
get
{
return (object[] /*(int, uint, uint, int)*/)this.GetRegisterValue((ushort)ProtoTestReg.RwI8U8U16I32, ProtoTestRegPack.RwI8U8U16I32);
return (object[] /*(int, uint, uint, int)*/)this.GetRegisterValues((ushort)ProtoTestReg.RwI8U8U16I32, ProtoTestRegPack.RwI8U8U16I32);
}
set
{

this.SetRegisterValue((ushort)ProtoTestReg.RwI8U8U16I32, ProtoTestRegPack.RwI8U8U16I32, value);
this.SetRegisterValues((ushort)ProtoTestReg.RwI8U8U16I32, ProtoTestRegPack.RwI8U8U16I32, value);
}

}
Expand All @@ -181,7 +181,7 @@ public byte[] RoBytes
{
get
{
return (object[] /*(int, uint, uint, int)*/)this.GetRegisterValue((ushort)ProtoTestReg.RoI8U8U16I32, ProtoTestRegPack.RoI8U8U16I32);
return (object[] /*(int, uint, uint, int)*/)this.GetRegisterValues((ushort)ProtoTestReg.RoI8U8U16I32, ProtoTestRegPack.RoI8U8U16I32);
}
}

Expand All @@ -192,12 +192,12 @@ public byte[] RoBytes
{
get
{
return (object[] /*(uint, string)*/)this.GetRegisterValue((ushort)ProtoTestReg.RwU8String, ProtoTestRegPack.RwU8String);
return (object[] /*(uint, string)*/)this.GetRegisterValues((ushort)ProtoTestReg.RwU8String, ProtoTestRegPack.RwU8String);
}
set
{

this.SetRegisterValue((ushort)ProtoTestReg.RwU8String, ProtoTestRegPack.RwU8String, value);
this.SetRegisterValues((ushort)ProtoTestReg.RwU8String, ProtoTestRegPack.RwU8String, value);
}

}
Expand All @@ -209,7 +209,7 @@ public byte[] RoBytes
{
get
{
return (object[] /*(uint, string)*/)this.GetRegisterValue((ushort)ProtoTestReg.RoU8String, ProtoTestRegPack.RoU8String);
return (object[] /*(uint, string)*/)this.GetRegisterValues((ushort)ProtoTestReg.RoU8String, ProtoTestRegPack.RoU8String);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Jacdac/Clients/RealTimeClockClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public RealTimeClockClient(JDBus bus, string name)
{
get
{
return (object[] /*(uint, uint, uint, uint, uint, uint, uint)*/)this.GetRegisterValue((ushort)RealTimeClockReg.LocalTime, RealTimeClockRegPack.LocalTime);
return (object[] /*(uint, uint, uint, uint, uint, uint, uint)*/)this.GetRegisterValues((ushort)RealTimeClockReg.LocalTime, RealTimeClockRegPack.LocalTime);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Jacdac/Clients/RoverClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public RoverClient(JDBus bus, string name)
{
get
{
return (object[] /*(float, float, float, float, float)*/)this.GetRegisterValue((ushort)RoverReg.Kinematics, RoverRegPack.Kinematics);
return (object[] /*(float, float, float, float, float)*/)this.GetRegisterValues((ushort)RoverReg.Kinematics, RoverRegPack.Kinematics);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Jacdac/Clients/VerifiedTelemetryClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public VerifiedTelemetryFingerprintType FingerprintType
{
get
{
return (object[] /*(uint, byte[])*/)this.GetRegisterValue((ushort)VerifiedTelemetryReg.FingerprintTemplate, VerifiedTelemetryRegPack.FingerprintTemplate);
return (object[] /*(uint, byte[])*/)this.GetRegisterValues((ushort)VerifiedTelemetryReg.FingerprintTemplate, VerifiedTelemetryRegPack.FingerprintTemplate);
}
}

Expand Down

0 comments on commit 7649bd8

Please sign in to comment.