Skip to content

Commit

Permalink
add XC-ESC Technology DroneCAN ESC Support!
Browse files Browse the repository at this point in the history
  • Loading branch information
lcago committed Jan 6, 2025
1 parent e6bfc67 commit c94b8de
Show file tree
Hide file tree
Showing 23 changed files with 821 additions and 3 deletions.
8 changes: 7 additions & 1 deletion ExtLibs/DroneCAN/canard_dsdlc/messages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ public static (Type type,UInt16 msgid, ulong crcseed, Func<Byte[],int, bool, obj
(typeof(com_hobbywing_esc_GetMaintenanceInformation_res), 241, 0xB81DBD4EC9A5977D, (b,s,fd) => com_hobbywing_esc_GetMaintenanceInformation_res.ByteArrayToDroneCANMsg(b,s,fd)),
(typeof(com_hobbywing_esc_GetMajorConfig_req), 242, 0x1506774DA3930BFD, (b,s,fd) => com_hobbywing_esc_GetMajorConfig_req.ByteArrayToDroneCANMsg(b,s,fd)),
(typeof(com_hobbywing_esc_GetMajorConfig_res), 242, 0x1506774DA3930BFD, (b,s,fd) => com_hobbywing_esc_GetMajorConfig_res.ByteArrayToDroneCANMsg(b,s,fd)),
(typeof(com_tmotor_esc_ParamCfg), 1033, 0x948F5E0B33E0EDEE, (b,s,fd) => com_tmotor_esc_ParamCfg.ByteArrayToDroneCANMsg(b,s,fd)),
(typeof(com_xckj_esc_CmdControl), 20110, 0x4df8b5792b8e676a, (b,s,fd) => com_xckj_esc_CmdControl.ByteArrayToDroneCANMsg(b,s,fd)),
(typeof(com_xckj_esc_OperateId), 20111, 0x4fdf12a8708a2030, (b,s,fd) => com_xckj_esc_OperateId.ByteArrayToDroneCANMsg(b,s,fd)),
(typeof(com_xckj_esc_AutoUpMsg1), 20130, 0xb95f98a2bb955035, (b,s,fd) => com_xckj_esc_AutoUpMsg1.ByteArrayToDroneCANMsg(b,s,fd)),
(typeof(com_xckj_esc_AutoUpMsg2), 20131, 0x2c8e7c3aaca9e11e, (b,s,fd) => com_xckj_esc_AutoUpMsg2.ByteArrayToDroneCANMsg(b,s,fd)),
(typeof(com_xckj_esc_ThrotGroup1), 20150, 0x8dfd4ad6e74b6207, (b,s,fd) => com_xckj_esc_ThrotGroup1.ByteArrayToDroneCANMsg(b,s,fd)),
(typeof(com_xckj_esc_ThrotGroup2), 20151, 0xa28b683d1286d1fc, (b,s,fd) => com_xckj_esc_ThrotGroup2.ByteArrayToDroneCANMsg(b,s,fd)),
(typeof(com_tmotor_esc_ParamCfg), 1033, 0x948F5E0B33E0EDEE, (b,s,fd) => com_tmotor_esc_ParamCfg.ByteArrayToDroneCANMsg(b,s,fd)),
(typeof(com_tmotor_esc_FocCtrl), 1035, 0x598143612FBC000B, (b,s,fd) => com_tmotor_esc_FocCtrl.ByteArrayToDroneCANMsg(b,s,fd)),
(typeof(com_tmotor_esc_PUSHSCI), 1038, 0xCE2B6D6B6BDC0AE8, (b,s,fd) => com_tmotor_esc_PUSHSCI.ByteArrayToDroneCANMsg(b,s,fd)),
(typeof(com_tmotor_esc_PUSHCAN), 1039, 0xAACF9B4B2577BC6E, (b,s,fd) => com_tmotor_esc_PUSHCAN.ByteArrayToDroneCANMsg(b,s,fd)),
Expand Down
12 changes: 12 additions & 0 deletions ExtLibs/DroneCAN/dsdl/com/xckj/esc/20110.CmdControl.uavcan
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
OVERRIDE_SIGNATURE 0x4fdf12a8708a2030

uint8 NODECMD_DIS_ALL_UP = 0
uint8 NODECMD_DIS_UP = 1
uint8 NODECMD_TRIG_HB = 10
uint8 NODECMD_EN_ALLUP = 100
uint8 NODECMD_RST = 0xFE
uint8 NodeCmd

uint8 CmdNodeId

uint8 reserved
3 changes: 3 additions & 0 deletions ExtLibs/DroneCAN/dsdl/com/xckj/esc/20111.OperateId.uavcan
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
OVERRIDE_SIGNATURE 0x4df8b5792b8e676a

uint8[<=3] payload
5 changes: 5 additions & 0 deletions ExtLibs/DroneCAN/dsdl/com/xckj/esc/20130.AutoUpMsg1.uavcan
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
OVERRIDE_SIGNATURE 0xb95f98a2bb955035

uint16 rpm
uint16 current
uint16 runstatus
7 changes: 7 additions & 0 deletions ExtLibs/DroneCAN/dsdl/com/xckj/esc/20131.AutoUpMsg2.uavcan
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
OVERRIDE_SIGNATURE 0x2c8e7c3aaca9e11e

uint16 PWM
uint16 voltage
uint8 MOS_T
uint8 CAP_T
uint8 Motor_T
3 changes: 3 additions & 0 deletions ExtLibs/DroneCAN/dsdl/com/xckj/esc/20150.ThrotGroup1.uavcan
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
OVERRIDE_SIGNATURE 0x8dfd4ad6e74b6207

uint14[<=4] command
3 changes: 3 additions & 0 deletions ExtLibs/DroneCAN/dsdl/com/xckj/esc/20151.ThrotGroup2.uavcan
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
OVERRIDE_SIGNATURE 0xa28b683d1286d1fc

uint14[<=4] command
5 changes: 5 additions & 0 deletions ExtLibs/DroneCAN/dsdl/com/xckj/esc/222.SetBaud.uavcan
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
OVERRIDE_SIGNATURE 0x278afc50d7f6f50d

uint8 baud
---
uint8 ok
9 changes: 9 additions & 0 deletions ExtLibs/DroneCAN/dsdl/com/xckj/esc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
XC TECHNOLOGY CAN ESC
=====================

These messages are applicable to the CAN ESCs of Shenzhen XC-ESC Technology Co., Ltd. (http://www.xc-bldc.com/).

note:
the default CAN baud rate of these Xiongcai Technology ESCs is 500,000, but it can be changed using the "SetBaud" command.

The default CAN node ID is 0x10, and it can be changed using the "SetID" command.
49 changes: 49 additions & 0 deletions ExtLibs/DroneCAN/out/include/com.xckj.AutoUpMsg1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using uint8_t = System.Byte;
using uint16_t = System.UInt16;
using uint32_t = System.UInt32;
using uint64_t = System.UInt64;

using int8_t = System.SByte;
using int16_t = System.Int16;
using int32_t = System.Int32;
using int64_t = System.Int64;

using float32 = System.Single;

using System;
using System.Linq;
using System.Runtime.InteropServices;

namespace DroneCAN
{
public partial class DroneCAN
{
public partial class com_xckj_esc_AutoUpMsg1 : IDroneCANSerialize
{
public const int COM_XCKJ_ESC_AUTOUPMSG1_MAX_PACK_SIZE = 6;
public const ulong COM_XCKJ_ESC_AUTOUPMSG1_DT_SIG = 0xb95f98a2bb955035;
public const int COM_XCKJ_ESC_AUTOUPMSG1_DT_ID = 20130;

public uint16_t rpm = new uint16_t();
public uint16_t current = new uint16_t();
public uint16_t runstatus = new uint16_t();

public void encode(dronecan_serializer_chunk_cb_ptr_t chunk_cb, object ctx, bool fdcan = false)
{
encode_com_xckj_esc_AutoUpMsg1(this, chunk_cb, ctx, fdcan);
}

public void decode(CanardRxTransfer transfer, bool fdcan = false)
{
decode_com_xckj_esc_AutoUpMsg1(transfer, this, fdcan);
}

public static com_xckj_esc_AutoUpMsg1 ByteArrayToDroneCANMsg(byte[] transfer, int startoffset, bool fdcan = false)
{
var ans = new com_xckj_esc_AutoUpMsg1();
ans.decode(new DroneCAN.CanardRxTransfer(transfer.Skip(startoffset).ToArray()), fdcan);
return ans;
}
}
}
}
51 changes: 51 additions & 0 deletions ExtLibs/DroneCAN/out/include/com.xckj.AutoUpMsg2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using uint8_t = System.Byte;
using uint16_t = System.UInt16;
using uint32_t = System.UInt32;
using uint64_t = System.UInt64;

using int8_t = System.SByte;
using int16_t = System.Int16;
using int32_t = System.Int32;
using int64_t = System.Int64;

using float32 = System.Single;

using System;
using System.Linq;
using System.Runtime.InteropServices;

namespace DroneCAN
{
public partial class DroneCAN
{
public partial class com_xckj_esc_AutoUpMsg2 : IDroneCANSerialize
{
public const int COM_XCKJ_ESC_AUTOUPMSG2_MAX_PACK_SIZE = 7;
public const ulong COM_XCKJ_ESC_AUTOUPMSG2_DT_SIG = 0x2c8e7c3aaca9e11e;
public const int COM_XCKJ_ESC_AUTOUPMSG2_DT_ID = 20131;

public uint16_t PWM = new uint16_t();
public uint16_t voltage = new uint16_t();
public uint8_t MOS_T = new uint8_t();
public uint8_t CAP_T = new uint8_t();
public uint8_t Motor_T = new uint8_t();

public void encode(dronecan_serializer_chunk_cb_ptr_t chunk_cb, object ctx, bool fdcan = false)
{
encode_com_xckj_esc_AutoUpMsg2(this, chunk_cb, ctx, fdcan);
}

public void decode(CanardRxTransfer transfer, bool fdcan = false)
{
decode_com_xckj_esc_AutoUpMsg2(transfer, this, fdcan);
}

public static com_xckj_esc_AutoUpMsg2 ByteArrayToDroneCANMsg(byte[] transfer, int startoffset, bool fdcan = false)
{
var ans = new com_xckj_esc_AutoUpMsg2();
ans.decode(new DroneCAN.CanardRxTransfer(transfer.Skip(startoffset).ToArray()), fdcan);
return ans;
}
}
}
}
54 changes: 54 additions & 0 deletions ExtLibs/DroneCAN/out/include/com.xckj.CmdControl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using uint8_t = System.Byte;
using uint16_t = System.UInt16;
using uint32_t = System.UInt32;
using uint64_t = System.UInt64;

using int8_t = System.SByte;
using int16_t = System.Int16;
using int32_t = System.Int32;
using int64_t = System.Int64;

using float32 = System.Single;

using System;
using System.Linq;
using System.Runtime.InteropServices;

namespace DroneCAN
{
public partial class DroneCAN
{
public partial class com_xckj_esc_CmdControl: IDroneCANSerialize
{
public const int COM_XCKJ_ESC_CMDCONTROL_MAX_PACK_SIZE = 4;
public const ulong COM_XCKJ_ESC_CMDCONTROL_DT_SIG = 0x4fdf12a8708a2030;
public const int COM_XCKJ_ESC_CMDCONTROL_DT_ID = 20110;

public const double COM_XCKJ_ESC_CMDCONTROL_NODECMD_DIS_ALL_UP = 0;
public const double COM_XCKJ_ESC_CMDCONTROL_NODECMD_DIS_UP = 1;
public const double COM_XCKJ_ESC_CMDCONTROL_NODECMD_TRIG_HB = 10;
public const double COM_XCKJ_ESC_CMDCONTROL_NODECMD_EN_ALLUP = 100;
public const double COM_XCKJ_ESC_CMDCONTROL_NODECMD_RST = 0xFEU;

public uint8_t NodeCmd = new uint8_t();
public uint8_t CmdNodeId = new uint8_t();
public uint8_t reserved = new uint8_t();

public void encode(dronecan_serializer_chunk_cb_ptr_t chunk_cb, object ctx, bool fdcan = false)
{
encode_com_xckj_esc_CmdControl(this, chunk_cb, ctx, fdcan);
}
public void decode(CanardRxTransfer transfer, bool fdcan = false)
{
decode_com_xckj_esc_CmdControl(transfer, this, fdcan);
}
public static com_xckj_esc_CmdControl ByteArrayToDroneCANMsg(byte[] transfer, int startoffset, bool fdcan = false)
{
var ans = new com_xckj_esc_CmdControl();
ans.decode(new DroneCAN.CanardRxTransfer(transfer.Skip(startoffset).ToArray()), fdcan);
return ans;
}
}
}

}
46 changes: 46 additions & 0 deletions ExtLibs/DroneCAN/out/include/com.xckj.OperateId.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using uint8_t = System.Byte;
using uint16_t = System.UInt16;
using uint32_t = System.UInt32;
using uint64_t = System.UInt64;

using int8_t = System.SByte;
using int16_t = System.Int16;
using int32_t = System.Int32;
using int64_t = System.Int64;

using float32 = System.Single;

using System;
using System.Linq;
using System.Runtime.InteropServices;

namespace DroneCAN
{
public partial class DroneCAN
{
public partial class com_xckj_esc_OperateId : IDroneCANSerialize
{
public const int COM_XCKJ_ESC_OPERATEID_MAX_PACK_SIZE = 4;
public const ulong COM_XCKJ_ESC_OPERATEID_DT_SIG = 0x4df8b5792b8e676a;
public const int COM_XCKJ_ESC_OPERATEID_DT_ID = 20111;

public uint8_t payload_len; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public uint8_t[] payload = Enumerable.Range(1, 3).Select(i => new uint8_t()).ToArray();

public void encode(dronecan_serializer_chunk_cb_ptr_t chunk_cb, object ctx, bool fdcan = false)
{
encode_com_xckj_esc_OperateId(this, chunk_cb, ctx, fdcan);
}
public void decode(CanardRxTransfer transfer, bool fdcan = false)
{
decode_com_xckj_esc_OperateId(transfer, this, fdcan);
}
public static com_xckj_esc_OperateId ByteArrayToDroneCANMsg(byte[] transfer, int startoffset, bool fdcan = false)
{
var ans = new com_xckj_esc_OperateId();
ans.decode(new DroneCAN.CanardRxTransfer(transfer.Skip(startoffset).ToArray()), fdcan);
return ans;
}
}
}

}
46 changes: 46 additions & 0 deletions ExtLibs/DroneCAN/out/include/com.xckj.ThrotGroup1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using uint8_t = System.Byte;
using uint16_t = System.UInt16;
using uint32_t = System.UInt32;
using uint64_t = System.UInt64;

using int8_t = System.SByte;
using int16_t = System.Int16;
using int32_t = System.Int32;
using int64_t = System.Int64;

using float32 = System.Single;

using System;
using System.Linq;
using System.Runtime.InteropServices;

namespace DroneCAN
{
public partial class DroneCAN
{
public partial class com_xckj_esc_ThrotGroup1 : IDroneCANSerialize
{
public const int COM_XCKJ_ESC_THROTGROUP1_MAX_PACK_SIZE = 7;
public const ulong COM_XCKJ_ESC_THROTGROUP1_DT_SIG = 0x8dfd4ad6e74b6207;
public const int COM_XCKJ_ESC_THROTGROUP1_DT_ID = 20150;

public uint8_t command_len; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public uint16_t[] command = Enumerable.Range(1, 4).Select(i => new uint16_t()).ToArray();

public void encode(dronecan_serializer_chunk_cb_ptr_t chunk_cb, object ctx, bool fdcan = false)
{
encode_com_xckj_esc_ThrotGroup1(this, chunk_cb, ctx, fdcan);
}
public void decode(CanardRxTransfer transfer, bool fdcan = false)
{
decode_com_xckj_esc_ThrotGroup1(transfer, this, fdcan);
}
public static com_xckj_esc_ThrotGroup1 ByteArrayToDroneCANMsg(byte[] transfer, int startoffset, bool fdcan = false)
{
var ans = new com_xckj_esc_ThrotGroup1();
ans.decode(new DroneCAN.CanardRxTransfer(transfer.Skip(startoffset).ToArray()), fdcan);
return ans;
}
}
}

}
46 changes: 46 additions & 0 deletions ExtLibs/DroneCAN/out/include/com.xckj.ThrotGroup2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using uint8_t = System.Byte;
using uint16_t = System.UInt16;
using uint32_t = System.UInt32;
using uint64_t = System.UInt64;

using int8_t = System.SByte;
using int16_t = System.Int16;
using int32_t = System.Int32;
using int64_t = System.Int64;

using float32 = System.Single;

using System;
using System.Linq;
using System.Runtime.InteropServices;

namespace DroneCAN
{
public partial class DroneCAN
{
public partial class com_xckj_esc_ThrotGroup2 : IDroneCANSerialize
{
public const int COM_XCKJ_ESC_THROTGROUP2_MAX_PACK_SIZE = 7;
public const ulong COM_XCKJ_ESC_THROTGROUP2_DT_SIG = 0xa28b683d1286d1fc;
public const int COM_XCKJ_ESC_THROTGROUP2_DT_ID = 20151;

public uint8_t command_len; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public uint16_t[] command = Enumerable.Range(1, 4).Select(i => new uint16_t()).ToArray();

public void encode(dronecan_serializer_chunk_cb_ptr_t chunk_cb, object ctx, bool fdcan = false)
{
encode_com_xckj_esc_ThrotGroup2(this, chunk_cb, ctx, fdcan);
}
public void decode(CanardRxTransfer transfer, bool fdcan = false)
{
decode_com_xckj_esc_ThrotGroup2(transfer, this, fdcan);
}
public static com_xckj_esc_ThrotGroup2 ByteArrayToDroneCANMsg(byte[] transfer, int startoffset, bool fdcan = false)
{
var ans = new com_xckj_esc_ThrotGroup2();
ans.decode(new DroneCAN.CanardRxTransfer(transfer.Skip(startoffset).ToArray()), fdcan);
return ans;
}
}
}

}
Loading

0 comments on commit c94b8de

Please sign in to comment.