本文整理汇总了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;
}
示例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;
}
示例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;
}