Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        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;
        }