From c94b8dea82e263719512875f8fa97dbea2f2c985 Mon Sep 17 00:00:00 2001 From: lcago <2080452042@qq.com> Date: Mon, 6 Jan 2025 16:56:23 +0800 Subject: [PATCH] add XC-ESC Technology DroneCAN ESC Support! --- ExtLibs/DroneCAN/canard_dsdlc/messages.cs | 8 +- .../dsdl/com/xckj/esc/20110.CmdControl.uavcan | 12 +++ .../dsdl/com/xckj/esc/20111.OperateId.uavcan | 3 + .../dsdl/com/xckj/esc/20130.AutoUpMsg1.uavcan | 5 ++ .../dsdl/com/xckj/esc/20131.AutoUpMsg2.uavcan | 7 ++ .../com/xckj/esc/20150.ThrotGroup1.uavcan | 3 + .../com/xckj/esc/20151.ThrotGroup2.uavcan | 3 + .../dsdl/com/xckj/esc/222.SetBaud.uavcan | 5 ++ ExtLibs/DroneCAN/dsdl/com/xckj/esc/README.md | 9 +++ .../out/include/com.xckj.AutoUpMsg1.cs | 49 ++++++++++++ .../out/include/com.xckj.AutoUpMsg2.cs | 51 ++++++++++++ .../out/include/com.xckj.CmdControl.cs | 54 +++++++++++++ .../out/include/com.xckj.OperateId.cs | 46 +++++++++++ .../out/include/com.xckj.ThrotGroup1.cs | 46 +++++++++++ .../out/include/com.xckj.ThrotGroup2.cs | 46 +++++++++++ .../DroneCAN/out/src/com.xckj.AutoUpMsg1.cs | 67 ++++++++++++++++ .../DroneCAN/out/src/com.xckj.AutoUpMsg2.cs | 79 +++++++++++++++++++ .../DroneCAN/out/src/com.xckj.CmdControl.cs | 59 ++++++++++++++ .../DroneCAN/out/src/com.xckj.ThrotGroup1.cs | 78 ++++++++++++++++++ .../DroneCAN/out/src/com.xckj.ThrotGroup2.cs | 78 ++++++++++++++++++ .../DroneCAN/out/src/com.xckj.operateid.cs | 78 ++++++++++++++++++ .../ConfigDroneCAN.Designer.cs | 13 ++- GCSViews/ConfigurationView/ConfigDroneCAN.cs | 25 ++++++ 23 files changed, 821 insertions(+), 3 deletions(-) create mode 100644 ExtLibs/DroneCAN/dsdl/com/xckj/esc/20110.CmdControl.uavcan create mode 100644 ExtLibs/DroneCAN/dsdl/com/xckj/esc/20111.OperateId.uavcan create mode 100644 ExtLibs/DroneCAN/dsdl/com/xckj/esc/20130.AutoUpMsg1.uavcan create mode 100644 ExtLibs/DroneCAN/dsdl/com/xckj/esc/20131.AutoUpMsg2.uavcan create mode 100644 ExtLibs/DroneCAN/dsdl/com/xckj/esc/20150.ThrotGroup1.uavcan create mode 100644 ExtLibs/DroneCAN/dsdl/com/xckj/esc/20151.ThrotGroup2.uavcan create mode 100644 ExtLibs/DroneCAN/dsdl/com/xckj/esc/222.SetBaud.uavcan create mode 100644 ExtLibs/DroneCAN/dsdl/com/xckj/esc/README.md create mode 100644 ExtLibs/DroneCAN/out/include/com.xckj.AutoUpMsg1.cs create mode 100644 ExtLibs/DroneCAN/out/include/com.xckj.AutoUpMsg2.cs create mode 100644 ExtLibs/DroneCAN/out/include/com.xckj.CmdControl.cs create mode 100644 ExtLibs/DroneCAN/out/include/com.xckj.OperateId.cs create mode 100644 ExtLibs/DroneCAN/out/include/com.xckj.ThrotGroup1.cs create mode 100644 ExtLibs/DroneCAN/out/include/com.xckj.ThrotGroup2.cs create mode 100644 ExtLibs/DroneCAN/out/src/com.xckj.AutoUpMsg1.cs create mode 100644 ExtLibs/DroneCAN/out/src/com.xckj.AutoUpMsg2.cs create mode 100644 ExtLibs/DroneCAN/out/src/com.xckj.CmdControl.cs create mode 100644 ExtLibs/DroneCAN/out/src/com.xckj.ThrotGroup1.cs create mode 100644 ExtLibs/DroneCAN/out/src/com.xckj.ThrotGroup2.cs create mode 100644 ExtLibs/DroneCAN/out/src/com.xckj.operateid.cs diff --git a/ExtLibs/DroneCAN/canard_dsdlc/messages.cs b/ExtLibs/DroneCAN/canard_dsdlc/messages.cs index d286b4ea11..0f1b8e1dc5 100644 --- a/ExtLibs/DroneCAN/canard_dsdlc/messages.cs +++ b/ExtLibs/DroneCAN/canard_dsdlc/messages.cs @@ -45,7 +45,13 @@ public static (Type type,UInt16 msgid, ulong crcseed, Func 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)), diff --git a/ExtLibs/DroneCAN/dsdl/com/xckj/esc/20110.CmdControl.uavcan b/ExtLibs/DroneCAN/dsdl/com/xckj/esc/20110.CmdControl.uavcan new file mode 100644 index 0000000000..c2e97cc66c --- /dev/null +++ b/ExtLibs/DroneCAN/dsdl/com/xckj/esc/20110.CmdControl.uavcan @@ -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 diff --git a/ExtLibs/DroneCAN/dsdl/com/xckj/esc/20111.OperateId.uavcan b/ExtLibs/DroneCAN/dsdl/com/xckj/esc/20111.OperateId.uavcan new file mode 100644 index 0000000000..f5ad240a22 --- /dev/null +++ b/ExtLibs/DroneCAN/dsdl/com/xckj/esc/20111.OperateId.uavcan @@ -0,0 +1,3 @@ +OVERRIDE_SIGNATURE 0x4df8b5792b8e676a + +uint8[<=3] payload diff --git a/ExtLibs/DroneCAN/dsdl/com/xckj/esc/20130.AutoUpMsg1.uavcan b/ExtLibs/DroneCAN/dsdl/com/xckj/esc/20130.AutoUpMsg1.uavcan new file mode 100644 index 0000000000..39095bb224 --- /dev/null +++ b/ExtLibs/DroneCAN/dsdl/com/xckj/esc/20130.AutoUpMsg1.uavcan @@ -0,0 +1,5 @@ +OVERRIDE_SIGNATURE 0xb95f98a2bb955035 + +uint16 rpm +uint16 current +uint16 runstatus diff --git a/ExtLibs/DroneCAN/dsdl/com/xckj/esc/20131.AutoUpMsg2.uavcan b/ExtLibs/DroneCAN/dsdl/com/xckj/esc/20131.AutoUpMsg2.uavcan new file mode 100644 index 0000000000..db1be76164 --- /dev/null +++ b/ExtLibs/DroneCAN/dsdl/com/xckj/esc/20131.AutoUpMsg2.uavcan @@ -0,0 +1,7 @@ +OVERRIDE_SIGNATURE 0x2c8e7c3aaca9e11e + +uint16 PWM +uint16 voltage +uint8 MOS_T +uint8 CAP_T +uint8 Motor_T diff --git a/ExtLibs/DroneCAN/dsdl/com/xckj/esc/20150.ThrotGroup1.uavcan b/ExtLibs/DroneCAN/dsdl/com/xckj/esc/20150.ThrotGroup1.uavcan new file mode 100644 index 0000000000..d786981437 --- /dev/null +++ b/ExtLibs/DroneCAN/dsdl/com/xckj/esc/20150.ThrotGroup1.uavcan @@ -0,0 +1,3 @@ +OVERRIDE_SIGNATURE 0x8dfd4ad6e74b6207 + +uint14[<=4] command diff --git a/ExtLibs/DroneCAN/dsdl/com/xckj/esc/20151.ThrotGroup2.uavcan b/ExtLibs/DroneCAN/dsdl/com/xckj/esc/20151.ThrotGroup2.uavcan new file mode 100644 index 0000000000..e5a410718d --- /dev/null +++ b/ExtLibs/DroneCAN/dsdl/com/xckj/esc/20151.ThrotGroup2.uavcan @@ -0,0 +1,3 @@ +OVERRIDE_SIGNATURE 0xa28b683d1286d1fc + +uint14[<=4] command diff --git a/ExtLibs/DroneCAN/dsdl/com/xckj/esc/222.SetBaud.uavcan b/ExtLibs/DroneCAN/dsdl/com/xckj/esc/222.SetBaud.uavcan new file mode 100644 index 0000000000..018dc1e4df --- /dev/null +++ b/ExtLibs/DroneCAN/dsdl/com/xckj/esc/222.SetBaud.uavcan @@ -0,0 +1,5 @@ +OVERRIDE_SIGNATURE 0x278afc50d7f6f50d + +uint8 baud +--- +uint8 ok diff --git a/ExtLibs/DroneCAN/dsdl/com/xckj/esc/README.md b/ExtLibs/DroneCAN/dsdl/com/xckj/esc/README.md new file mode 100644 index 0000000000..940c38a526 --- /dev/null +++ b/ExtLibs/DroneCAN/dsdl/com/xckj/esc/README.md @@ -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. diff --git a/ExtLibs/DroneCAN/out/include/com.xckj.AutoUpMsg1.cs b/ExtLibs/DroneCAN/out/include/com.xckj.AutoUpMsg1.cs new file mode 100644 index 0000000000..da33f6374f --- /dev/null +++ b/ExtLibs/DroneCAN/out/include/com.xckj.AutoUpMsg1.cs @@ -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; + } + } + } +} \ No newline at end of file diff --git a/ExtLibs/DroneCAN/out/include/com.xckj.AutoUpMsg2.cs b/ExtLibs/DroneCAN/out/include/com.xckj.AutoUpMsg2.cs new file mode 100644 index 0000000000..c62d8bf5b1 --- /dev/null +++ b/ExtLibs/DroneCAN/out/include/com.xckj.AutoUpMsg2.cs @@ -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; + } + } + } +} \ No newline at end of file diff --git a/ExtLibs/DroneCAN/out/include/com.xckj.CmdControl.cs b/ExtLibs/DroneCAN/out/include/com.xckj.CmdControl.cs new file mode 100644 index 0000000000..5282256a8a --- /dev/null +++ b/ExtLibs/DroneCAN/out/include/com.xckj.CmdControl.cs @@ -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; + } + } + } + +} diff --git a/ExtLibs/DroneCAN/out/include/com.xckj.OperateId.cs b/ExtLibs/DroneCAN/out/include/com.xckj.OperateId.cs new file mode 100644 index 0000000000..01acf5a1f9 --- /dev/null +++ b/ExtLibs/DroneCAN/out/include/com.xckj.OperateId.cs @@ -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; + } + } + } + +} diff --git a/ExtLibs/DroneCAN/out/include/com.xckj.ThrotGroup1.cs b/ExtLibs/DroneCAN/out/include/com.xckj.ThrotGroup1.cs new file mode 100644 index 0000000000..25eb4afd00 --- /dev/null +++ b/ExtLibs/DroneCAN/out/include/com.xckj.ThrotGroup1.cs @@ -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; + } + } + } + +} \ No newline at end of file diff --git a/ExtLibs/DroneCAN/out/include/com.xckj.ThrotGroup2.cs b/ExtLibs/DroneCAN/out/include/com.xckj.ThrotGroup2.cs new file mode 100644 index 0000000000..1c7a4489fc --- /dev/null +++ b/ExtLibs/DroneCAN/out/include/com.xckj.ThrotGroup2.cs @@ -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; + } + } + } + +} \ No newline at end of file diff --git a/ExtLibs/DroneCAN/out/src/com.xckj.AutoUpMsg1.cs b/ExtLibs/DroneCAN/out/src/com.xckj.AutoUpMsg1.cs new file mode 100644 index 0000000000..f2694cccdd --- /dev/null +++ b/ExtLibs/DroneCAN/out/src/com.xckj.AutoUpMsg1.cs @@ -0,0 +1,67 @@ + +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; +using System.Collections.Generic; + +namespace DroneCAN +{ + public partial class DroneCAN + { + + public partial class com_xckj_esc_AutoUpMsg1 : IDroneCANSerialize + { + public static void encode_com_xckj_esc_AutoUpMsg1(com_xckj_esc_AutoUpMsg1 msg, dronecan_serializer_chunk_cb_ptr_t chunk_cb, object ctx, bool fdcan) + { + uint8_t[] buffer = new uint8_t[8]; + _encode_com_xckj_esc_AutoUpMsg1(buffer, msg, chunk_cb, ctx, !fdcan); + } + + public static uint32_t decode_com_xckj_esc_AutoUpMsg1(CanardRxTransfer transfer, com_xckj_esc_AutoUpMsg1 msg, bool fdcan) + { + uint32_t bit_ofs = 0; + _decode_com_xckj_esc_AutoUpMsg1(transfer, ref bit_ofs, msg, !fdcan); + return (bit_ofs + 7) / 8; + } + + internal static void _encode_com_xckj_esc_AutoUpMsg1(uint8_t[] buffer, com_xckj_esc_AutoUpMsg1 msg, dronecan_serializer_chunk_cb_ptr_t chunk_cb, object ctx, bool tao) + { + memset(buffer, 0, 8); + canardEncodeScalar(buffer, 0, 16, msg.rpm); + chunk_cb(buffer, 16, ctx); + memset(buffer, 0, 8); + canardEncodeScalar(buffer, 0, 16, msg.current); + chunk_cb(buffer, 16, ctx); + memset(buffer, 0, 8); + canardEncodeScalar(buffer, 0, 16, msg.runstatus); + chunk_cb(buffer, 16, ctx); + } + + internal static void _decode_com_xckj_esc_AutoUpMsg1(CanardRxTransfer transfer, ref uint32_t bit_ofs, com_xckj_esc_AutoUpMsg1 msg, bool tao) + { + + canardDecodeScalar(transfer, bit_ofs, 16, false, ref msg.rpm); + bit_ofs += 16; + + canardDecodeScalar(transfer, bit_ofs, 16, false, ref msg.current); + bit_ofs += 16; + + canardDecodeScalar(transfer, bit_ofs, 16, false, ref msg.runstatus); + bit_ofs += 16; + + } + } + } +} \ No newline at end of file diff --git a/ExtLibs/DroneCAN/out/src/com.xckj.AutoUpMsg2.cs b/ExtLibs/DroneCAN/out/src/com.xckj.AutoUpMsg2.cs new file mode 100644 index 0000000000..b618e97d39 --- /dev/null +++ b/ExtLibs/DroneCAN/out/src/com.xckj.AutoUpMsg2.cs @@ -0,0 +1,79 @@ + +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; +using System.Collections.Generic; + +namespace DroneCAN +{ + public partial class DroneCAN + { + + public partial class com_xckj_esc_AutoUpMsg2 : IDroneCANSerialize + { + public static void encode_com_xckj_esc_AutoUpMsg2(com_xckj_esc_AutoUpMsg2 msg, dronecan_serializer_chunk_cb_ptr_t chunk_cb, object ctx, bool fdcan) + { + uint8_t[] buffer = new uint8_t[8]; + _encode_com_xckj_esc_AutoUpMsg2(buffer, msg, chunk_cb, ctx, !fdcan); + } + + public static uint32_t decode_com_xckj_esc_AutoUpMsg2(CanardRxTransfer transfer, com_xckj_esc_AutoUpMsg2 msg, bool fdcan) + { + uint32_t bit_ofs = 0; + _decode_com_xckj_esc_AutoUpMsg2(transfer, ref bit_ofs, msg, !fdcan); + return (bit_ofs + 7) / 8; + } + + internal static void _encode_com_xckj_esc_AutoUpMsg2(uint8_t[] buffer, com_xckj_esc_AutoUpMsg2 msg, dronecan_serializer_chunk_cb_ptr_t chunk_cb, object ctx, bool tao) + { + memset(buffer, 0, 8); + canardEncodeScalar(buffer, 0, 16, msg.PWM); + chunk_cb(buffer, 16, ctx); + memset(buffer, 0, 8); + canardEncodeScalar(buffer, 0, 16, msg.voltage); + chunk_cb(buffer, 16, ctx); + memset(buffer, 0, 8); + canardEncodeScalar(buffer, 0, 8, msg.MOS_T); + chunk_cb(buffer, 8, ctx); + memset(buffer, 0, 8); + canardEncodeScalar(buffer, 0, 8, msg.CAP_T); + chunk_cb(buffer, 8, ctx); + memset(buffer, 0, 8); + canardEncodeScalar(buffer, 0, 8, msg.Motor_T); + chunk_cb(buffer, 8, ctx); + } + + internal static void _decode_com_xckj_esc_AutoUpMsg2(CanardRxTransfer transfer, ref uint32_t bit_ofs, com_xckj_esc_AutoUpMsg2 msg, bool tao) + { + + canardDecodeScalar(transfer, bit_ofs, 16, false, ref msg.PWM); + bit_ofs += 16; + + canardDecodeScalar(transfer, bit_ofs, 16, false, ref msg.voltage); + bit_ofs += 16; + + canardDecodeScalar(transfer, bit_ofs, 8, false, ref msg.MOS_T); + bit_ofs += 8; + + canardDecodeScalar(transfer, bit_ofs, 8, false, ref msg.CAP_T); + bit_ofs += 8; + + canardDecodeScalar(transfer, bit_ofs, 8, false, ref msg.Motor_T); + bit_ofs += 8; + + } + } + } +} \ No newline at end of file diff --git a/ExtLibs/DroneCAN/out/src/com.xckj.CmdControl.cs b/ExtLibs/DroneCAN/out/src/com.xckj.CmdControl.cs new file mode 100644 index 0000000000..d9088c9efd --- /dev/null +++ b/ExtLibs/DroneCAN/out/src/com.xckj.CmdControl.cs @@ -0,0 +1,59 @@ + +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; +using System.Collections.Generic; + +namespace DroneCAN +{ + public partial class DroneCAN { + + public partial class com_xckj_esc_CmdControl : IDroneCANSerialize + { + public static void encode_com_xckj_esc_CmdControl(com_xckj_esc_CmdControl msg, dronecan_serializer_chunk_cb_ptr_t chunk_cb, object ctx, bool fdcan) { + uint8_t[] buffer = new uint8_t[8]; + _encode_com_xckj_esc_CmdControl(buffer, msg, chunk_cb, ctx, !fdcan); + } + + public static uint32_t decode_com_xckj_esc_CmdControl(CanardRxTransfer transfer, com_xckj_esc_CmdControl msg, bool fdcan) { + uint32_t bit_ofs = 0; + _decode_com_xckj_esc_CmdControl(transfer, ref bit_ofs, msg, !fdcan); + return (bit_ofs+7)/8; + } + + internal static void _encode_com_xckj_esc_CmdControl(uint8_t[] buffer, com_xckj_esc_CmdControl msg, dronecan_serializer_chunk_cb_ptr_t chunk_cb, object ctx, bool tao) { + memset(buffer, 0, 8); + canardEncodeScalar(buffer, 0, 8, msg.NodeCmd); + chunk_cb(buffer, 8, ctx); + memset(buffer, 0, 8); + canardEncodeScalar(buffer, 0, 8, msg.CmdNodeId); + chunk_cb(buffer, 8, ctx); + memset(buffer, 0, 8); + canardEncodeScalar(buffer, 0, 8, msg.reserved); + chunk_cb(buffer, 8, ctx); + } + + internal static void _decode_com_xckj_esc_CmdControl(CanardRxTransfer transfer,ref uint32_t bit_ofs, com_xckj_esc_CmdControl msg, bool tao) { + canardDecodeScalar(transfer, bit_ofs, 8, false, ref msg.NodeCmd); + bit_ofs += 8; + canardDecodeScalar(transfer, bit_ofs, 8, false, ref msg.CmdNodeId); + bit_ofs += 8; + canardDecodeScalar(transfer, bit_ofs, 8, false, ref msg.reserved); + bit_ofs += 8; + } + } + } + +} diff --git a/ExtLibs/DroneCAN/out/src/com.xckj.ThrotGroup1.cs b/ExtLibs/DroneCAN/out/src/com.xckj.ThrotGroup1.cs new file mode 100644 index 0000000000..fe2a9e4e2a --- /dev/null +++ b/ExtLibs/DroneCAN/out/src/com.xckj.ThrotGroup1.cs @@ -0,0 +1,78 @@ + +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; +using System.Collections.Generic; +using static DroneCAN.DroneCAN; + +namespace DroneCAN +{ + public partial class DroneCAN + { + + public partial class com_xckj_esc_ThrotGroup2 : IDroneCANSerialize + { + public static void encode_com_xckj_esc_ThrotGroup2(com_xckj_esc_ThrotGroup2 msg, dronecan_serializer_chunk_cb_ptr_t chunk_cb, object ctx, bool fdcan) + { + uint8_t[] buffer = new uint8_t[8]; + _encode_com_xckj_esc_ThrotGroup2(buffer, msg, chunk_cb, ctx, !fdcan); + } + + public static uint32_t decode_com_xckj_esc_ThrotGroup2(CanardRxTransfer transfer, com_xckj_esc_ThrotGroup2 msg, bool fdcan) + { + uint32_t bit_ofs = 0; + _decode_com_xckj_esc_ThrotGroup2(transfer, ref bit_ofs, msg, !fdcan); + return (bit_ofs + 7) / 8; + } + + internal static void _encode_com_xckj_esc_ThrotGroup2(uint8_t[] buffer, com_xckj_esc_ThrotGroup2 msg, dronecan_serializer_chunk_cb_ptr_t chunk_cb, object ctx, bool tao) + { + if (!tao) + { + memset(buffer, 0, 8); + canardEncodeScalar(buffer, 0, 2, msg.command_len); + chunk_cb(buffer, 2, ctx); + } + for (int i = 0; i < msg.command_len; i++) + { + memset(buffer, 0, 8); + canardEncodeScalar(buffer, 0, 8, msg.command[i]); + chunk_cb(buffer, 8, ctx); + } + } + + internal static void _decode_com_xckj_esc_ThrotGroup2(CanardRxTransfer transfer, ref uint32_t bit_ofs, com_xckj_esc_ThrotGroup2 msg, bool tao) + { + if (!tao) + { + canardDecodeScalar(transfer, bit_ofs, 4, false, ref msg.command_len); + bit_ofs += 4; + } + else + { + msg.command_len = (uint8_t)(((transfer.payload_len * 8) - bit_ofs) / 14); + } + + msg.command = new uint16_t[msg.command_len]; + for (int i = 0; i < msg.command_len; i++) + { + canardDecodeScalar(transfer, bit_ofs, 14, true, ref msg.command[i]); + bit_ofs += 14; + } + } + } + } + +} diff --git a/ExtLibs/DroneCAN/out/src/com.xckj.ThrotGroup2.cs b/ExtLibs/DroneCAN/out/src/com.xckj.ThrotGroup2.cs new file mode 100644 index 0000000000..30f5ae16d2 --- /dev/null +++ b/ExtLibs/DroneCAN/out/src/com.xckj.ThrotGroup2.cs @@ -0,0 +1,78 @@ + +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; +using System.Collections.Generic; +using static DroneCAN.DroneCAN; + +namespace DroneCAN +{ + public partial class DroneCAN + { + + public partial class com_xckj_esc_ThrotGroup1 : IDroneCANSerialize + { + public static void encode_com_xckj_esc_ThrotGroup1(com_xckj_esc_ThrotGroup1 msg, dronecan_serializer_chunk_cb_ptr_t chunk_cb, object ctx, bool fdcan) + { + uint8_t[] buffer = new uint8_t[8]; + _encode_com_xckj_esc_ThrotGroup1(buffer, msg, chunk_cb, ctx, !fdcan); + } + + public static uint32_t decode_com_xckj_esc_ThrotGroup1(CanardRxTransfer transfer, com_xckj_esc_ThrotGroup1 msg, bool fdcan) + { + uint32_t bit_ofs = 0; + _decode_com_xckj_esc_ThrotGroup1(transfer, ref bit_ofs, msg, !fdcan); + return (bit_ofs + 7) / 8; + } + + internal static void _encode_com_xckj_esc_ThrotGroup1(uint8_t[] buffer, com_xckj_esc_ThrotGroup1 msg, dronecan_serializer_chunk_cb_ptr_t chunk_cb, object ctx, bool tao) + { + if (!tao) + { + memset(buffer, 0, 8); + canardEncodeScalar(buffer, 0, 2, msg.command_len); + chunk_cb(buffer, 2, ctx); + } + for (int i = 0; i < msg.command_len; i++) + { + memset(buffer, 0, 8); + canardEncodeScalar(buffer, 0, 8, msg.command[i]); + chunk_cb(buffer, 8, ctx); + } + } + + internal static void _decode_com_xckj_esc_ThrotGroup1(CanardRxTransfer transfer, ref uint32_t bit_ofs, com_xckj_esc_ThrotGroup1 msg, bool tao) + { + if (!tao) + { + canardDecodeScalar(transfer, bit_ofs, 4, false, ref msg.command_len); + bit_ofs += 4; + } + else + { + msg.command_len = (uint8_t)(((transfer.payload_len * 8) - bit_ofs) / 14); + } + + msg.command = new uint16_t[msg.command_len]; + for (int i = 0; i < msg.command_len; i++) + { + canardDecodeScalar(transfer, bit_ofs, 14, true, ref msg.command[i]); + bit_ofs += 14; + } + } + } + } + +} diff --git a/ExtLibs/DroneCAN/out/src/com.xckj.operateid.cs b/ExtLibs/DroneCAN/out/src/com.xckj.operateid.cs new file mode 100644 index 0000000000..c14b0fcf5d --- /dev/null +++ b/ExtLibs/DroneCAN/out/src/com.xckj.operateid.cs @@ -0,0 +1,78 @@ + +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; +using System.Collections.Generic; +using static DroneCAN.DroneCAN; + +namespace DroneCAN +{ + public partial class DroneCAN + { + + public partial class com_xckj_esc_OperateId : IDroneCANSerialize + { + public static void encode_com_xckj_esc_OperateId(com_xckj_esc_OperateId msg, dronecan_serializer_chunk_cb_ptr_t chunk_cb, object ctx, bool fdcan) + { + uint8_t[] buffer = new uint8_t[8]; + _encode_com_xckj_esc_OperateId(buffer, msg, chunk_cb, ctx, !fdcan); + } + + public static uint32_t decode_com_xckj_esc_OperateId(CanardRxTransfer transfer, com_xckj_esc_OperateId msg, bool fdcan) + { + uint32_t bit_ofs = 0; + _decode_com_xckj_esc_OperateId(transfer, ref bit_ofs, msg, !fdcan); + return (bit_ofs + 7) / 8; + } + + internal static void _encode_com_xckj_esc_OperateId(uint8_t[] buffer, com_xckj_esc_OperateId msg, dronecan_serializer_chunk_cb_ptr_t chunk_cb, object ctx, bool tao) + { + if (!tao) + { + memset(buffer, 0, 8); + canardEncodeScalar(buffer, 0, 2, msg.payload_len); + chunk_cb(buffer, 2, ctx); + } + for (int i = 0; i < msg.payload_len; i++) + { + memset(buffer, 0, 8); + canardEncodeScalar(buffer, 0, 8, msg.payload[i]); + chunk_cb(buffer, 8, ctx); + } + } + + internal static void _decode_com_xckj_esc_OperateId(CanardRxTransfer transfer, ref uint32_t bit_ofs, com_xckj_esc_OperateId msg, bool tao) + { + if (!tao) + { + canardDecodeScalar(transfer, bit_ofs, 2, false, ref msg.payload_len); + bit_ofs += 2; + } + else + { + msg.payload_len = (uint8_t)(((transfer.payload_len * 8) - bit_ofs) / 8); + } + + msg.payload = new uint8_t[msg.payload_len]; + for (int i = 0; i < msg.payload_len; i++) + { + canardDecodeScalar(transfer, bit_ofs, 8, false, ref msg.payload[i]); + bit_ofs += 8; + } + } + } + } + +} \ No newline at end of file diff --git a/GCSViews/ConfigurationView/ConfigDroneCAN.Designer.cs b/GCSViews/ConfigurationView/ConfigDroneCAN.Designer.cs index 3e6c595c3f..7453465161 100644 --- a/GCSViews/ConfigurationView/ConfigDroneCAN.Designer.cs +++ b/GCSViews/ConfigurationView/ConfigDroneCAN.Designer.cs @@ -40,6 +40,7 @@ private void InitializeComponent() this.menu_updatebeta = new System.Windows.Forms.MenuItem(); this.menu_passthrough = new System.Windows.Forms.MenuItem(); this.menu_passthrough4 = new System.Windows.Forms.MenuItem(); + this.menu_xc_esc_setid = new System.Windows.Forms.MenuItem(); this.label1 = new System.Windows.Forms.Label(); this.but_uavcaninspector = new MissionPlanner.Controls.MyButton(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); @@ -117,7 +118,8 @@ private void InitializeComponent() this.menu_update, this.menu_updatebeta, this.menu_passthrough, - this.menu_passthrough4}); + this.menu_passthrough4, + this.menu_xc_esc_setid}); // // menu_parameters // @@ -154,7 +156,13 @@ private void InitializeComponent() // this.menu_passthrough4.Index = 5; this.menu_passthrough4.Text = "CANPassThough Here3+/4"; - this.menu_passthrough4.Click += new System.EventHandler(this.menu_passthrough4_Click); + this.menu_passthrough4.Click += new System.EventHandler(this.menu_passthrough4_Click); + // + // menu_xc_esc_setid + // + this.menu_xc_esc_setid.Index = 6; + this.menu_xc_esc_setid.Text = "XC-ESC SetID"; + this.menu_xc_esc_setid.Click += new System.EventHandler(this.menu_xc_esc_setid_Click); // // label1 // @@ -674,6 +682,7 @@ private void InitializeComponent() private System.Windows.Forms.DataGridViewTextBoxColumn SoftwareCRC; private System.Windows.Forms.DataGridViewButtonColumn Menu; private System.Windows.Forms.MenuItem menu_passthrough4; + private System.Windows.Forms.MenuItem menu_xc_esc_setid; private Controls.MyButton but_stats; private System.Windows.Forms.ComboBox cmb_interfacetype; private System.Windows.Forms.ComboBox cmb_networkinterface; diff --git a/GCSViews/ConfigurationView/ConfigDroneCAN.cs b/GCSViews/ConfigurationView/ConfigDroneCAN.cs index 08b33c3c76..8e8229fd6d 100644 --- a/GCSViews/ConfigurationView/ConfigDroneCAN.cs +++ b/GCSViews/ConfigurationView/ConfigDroneCAN.cs @@ -21,6 +21,8 @@ using MissionPlanner.ArduPilot; using System.Runtime.InteropServices; using System.Net.NetworkInformation; +using Org.BouncyCastle.Bcpg; +using System.IO.Packaging; namespace MissionPlanner.GCSViews.ConfigurationView { @@ -1176,7 +1178,30 @@ private void menu_passthrough4_Click(object sender, EventArgs e) } }); } + private void menu_xc_esc_setid_Click(object sender, EventArgs e) + { + if (listener != null) + { + menu_passthrough4.Checked = false; + listener.Stop(); + CustomMessageBox.Show("Stop", "Disabled forwarding"); + listener = null; + return; + } + var id = int.Parse(myDataGridView1.CurrentRow.Cells[iDDataGridViewTextBoxColumn.Index].Value + .ToString()); + if (InputBox.Show("Set XC-ESC ID(must only one XC-ESC)", "Enter Id", ref id) == DialogResult.OK) + { + var slcan = can.PackageMessageSLCAN(0, 16, can.TransferID++, + new DroneCAN.DroneCAN.com_xckj_esc_OperateId() + { + payload_len = 3, + payload = new byte[] {0, (byte)id, (byte)id}, + }); + can.WriteToStreamSLCAN(slcan); + } + } public class CanStats : dronecan_protocol_CanStats { public int NodeID { get; set; }