C# sample code.
Posted: Fri 5. Apr 2019, 09:02
I can see we have C# sample code for ISOTP and PCAN basic. Do you or anyone have a sample code for client side C# UDS sample?
Code: Select all
private void buttonInit_Click(object sender, EventArgs e)
{
TPUDSCANHandle p_handle;
TPUDSStatus sts;
p_handle = UDSApi.PUDS_USBBUS1;
sts = UDSApi.Initialize(p_handle, TPUDSBaudrate.PUDS_BAUD_1M, 0, 0, 0);
if(sts == TPUDSStatus.PUDS_ERROR_OK)
{
TextSts.Text = "initilize";
}
}
please let me know what wrong is happening?System.BadImageFormatException
HResult=0x8007000B
Message=An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
Source=PcanIsoTpExample
StackTrace:
at Peak.Can.Uds.UDSApi.Initialize(UInt16 CanChannel, TPUDSBaudrate Baudrate, TPUDSHWType HwType, UInt32 IOPort, UInt16 Interrupt)
at PcanIsoTpExample.udsForm.buttonInit_Click(Object sender, EventArgs e) in F:\Projects\traction_inverter\Pcan\UDS\Mycodes\Delta_UDS_boot\udsForm.cs:line 793
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Code: Select all
System.BadImageFormatException was unhandled
HResult=-2147024885
Message=An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
Source=PcanIsoTpExample
StackTrace:
at Peak.Can.IsoTp.CanTpApi.GetValue(UInt16 CanChannel, TPCANTPParameter Parameter, StringBuilder StringBuffer, UInt32 BufferLength)
at PcanIsoTpExample.FormMain..ctor() in D:\iTester\TEST_PROGRAMS\Team20\Google_Jolt\PCAN-ISO-TP\PCAN-ISO-TP\Samples\PcanIsoTpExample\C#\FormMain.cs:line 89
at PcanIsoTpExample.Program.Main() in D:\iTester\TEST_PROGRAMS\Team20\Google_Jolt\PCAN-ISO-TP\PCAN-ISO-TP\Samples\PcanIsoTpExample\C#\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
laktej wrote:thank you so much for the reply. it works now.
i followed this below url
https://www.peak-system.com/forum/viewt ... 182&t=2912