当前位置: 首页>>代码示例>>C#>>正文


C# IntPtr.AsStruct方法代码示例

本文整理汇总了C#中System.IntPtr.AsStruct方法的典型用法代码示例。如果您正苦于以下问题:C# IntPtr.AsStruct方法的具体用法?C# IntPtr.AsStruct怎么用?C# IntPtr.AsStruct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IntPtr的用法示例。


在下文中一共展示了IntPtr.AsStruct方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PassThruStartPeriodicMsg

        public static J2534Err PassThruStartPeriodicMsg(int channelId, IntPtr msg, ref int msgId, int timeInterval)
        {
            Log.WriteTimestamp("", "PTStartPeriodicMsg({0}, 0x{1}, {2}, {3})", channelId, msg.ToString("X8"), msgId, timeInterval);
            Log.WriteLine(msg.AsStruct<PassThruMsg>().ToString("\t"));

            var result = Loader.Lib.PassThruStartPeriodicMsg(channelId, msg, ref msgId, timeInterval);

            Log.WriteTimestamp("  ", "{0}: {1}", (int)result, result);

            return result;
        }
开发者ID:mkelly,项目名称:J2534DotNet,代码行数:11,代码来源:Logger.cs

示例2: PassThruIoctl

        public static int PassThruIoctl(int channelId, Ioctl ioctlID, IntPtr input, IntPtr output)
        {
            Log.WriteTimestamp("", "PTIoctl({0}, {1}, 0x{2}, 0x{3})", channelId, ioctlID, input.ToString("X8"),
                output.ToString("X8"));

            if (input == IntPtr.Zero)
            {
                Log.WriteLine("  Input is null");
            }
            else
            {
                Log.Write("  Input: ");
                switch (ioctlID)
                {
                    case Ioctl.SET_CONFIG:
                        var configList = input.AsStruct<SConfigList>();
                        if (configList.Count > 0) Log.WriteLine("");
                        foreach (var config in configList.GetList())
                        {
                            Log.WriteLine("  {0} = {1}", config.Parameter, config.Value);
                        }
                        break;
                    case Ioctl.FAST_INIT:
                        Log.WriteLine(input.AsStruct<PassThruMsg>().ToString("\t"));
                        break;
                    case Ioctl.FIVE_BAUD_INIT:
                    case Ioctl.ADD_TO_FUNCT_MSG_LOOKUP_TABLE:
                    case Ioctl.DELETE_FROM_FUNCT_MSG_LOOKUP_TABLE:
                        Log.WriteLine(Environment.NewLine + "    " + input.AsStruct<SByteArray>().ToString());
                        break;
                    default:
                        Log.WriteLine("");
                        break;
                }
            }

            var result = Loader.Lib.PassThruIoctl(channelId, (int)ioctlID, input, output);

            if (result == J2534Err.STATUS_NOERROR)
            {
                if (output == IntPtr.Zero)
                {
                    Log.WriteLine("  Output is null");
                }
                else
                {
                    Log.Write("  Output:");
                    switch (ioctlID)
                    {
                        case Ioctl.GET_CONFIG:
                            var configList = input.AsStruct<SConfigList>();
                            foreach (var config in configList.GetList())
                            {
                                Log.WriteLine("    {0} = {1}", config.Parameter, config.Value);
                            }
                            break;
                        case Ioctl.READ_VBATT:
                        case Ioctl.READ_PROG_VOLTAGE:
                            Log.WriteLine(" {0:#.000} Volts", output.AsStruct<uint>() / 1000.0);
                            break;
                        case Ioctl.FAST_INIT:
                            Log.WriteLine(output.AsStruct<PassThruMsg>().ToString("\t"));
                            break;
                        case Ioctl.FIVE_BAUD_INIT:
                            Log.WriteLine(Environment.NewLine + "    " + input.AsStruct<SByteArray>().ToString());
                            break;
                        default:
                            Log.WriteLine("");
                            break;
                    }
                }
            }

            Log.WriteTimestamp("  ", "{0}: {1}", (int)result, result);

            return (int)result;
        }
开发者ID:mkelly,项目名称:J2534DotNet,代码行数:77,代码来源:Logger.cs

示例3: PassThruStartMsgFilter

        public static J2534Err PassThruStartMsgFilter(int channelid, int filterType, IntPtr maskMsg,
            IntPtr patternMsg, IntPtr flowControlMsg, ref int filterId)
        {
            Log.WriteTimestamp("", "PTStartMsgFilter({0}, {1}, 0x{2}, 0x{3}, 0x{4}, {5})",
                channelid,
                filterType,
                maskMsg.ToString("X8"),
                patternMsg.ToString("X8"),
                flowControlMsg.ToString("X8"),
                filterId);

            Log.WriteLine("  maskMsg: {0}", maskMsg.AsStruct<PassThruMsg>().ToString("\t"));
            Log.WriteLine("  patternMsg: {0}", patternMsg.AsStruct<PassThruMsg>().ToString("\t"));
            Log.WriteLine("  flowControlMsg: {0}", flowControlMsg.AsStruct<PassThruMsg>().ToString("\t"));

            var result = Loader.Lib.PassThruStartMsgFilter(channelid, (FilterType)filterType, maskMsg,
                patternMsg, flowControlMsg, ref filterId);

            Log.WriteTimestamp("  ", "{0}: {1}", (int)result, result);

            return result;
        }
开发者ID:mkelly,项目名称:J2534DotNet,代码行数:22,代码来源:Logger.cs


注:本文中的System.IntPtr.AsStruct方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。