A free API for the communication with control devices according to UDS (ISO 14229-1)
-
Ken0711
- Posts: 21
- Joined: Wed 19. Jul 2023, 03:04
Post
by Ken0711 » Fri 17. Nov 2023, 12:18
Hi Peak CAN Support ,
I use C# generate .exe File to flashed ,when Init Hardware ,feedback PCAN_ERROR_ALREADY Initialize
only the first time Init Ok,
I checked by PCAN view ,feedback the hardware already used
I knew possible someplace not release the hardware ,can you give me suggestion to how to handle it ?
Thanks!
-
Attachments
-

- Capture.PNG (8.01 KiB) Viewed 9117 times
-
K.Wagner
- Software Development

- Posts: 1082
- Joined: Wed 22. Sep 2010, 13:36
Post
by K.Wagner » Fri 17. Nov 2023, 13:24
Hello,
the error PUDS_ERROR_ALREADY_INITIALIZED will be returned, when it is tried to initialize a channel that has been already ininitalized (is in use) by the same process.
Please note that a PCAN channel can be connected only once at a time from PCAN-Basic. PCAN-View and any other applications written using the professional version of the API, PCAN-API (a.k.a. CanApi4), do not have this limitation.
Best regards,
Keneth
-
Ken0711
- Posts: 21
- Joined: Wed 19. Jul 2023, 03:04
Post
by Ken0711 » Fri 17. Nov 2023, 13:31
Hi ,
I got the means ,so i wanted when first time initialize success,after flashing ,how to release the hardware(puds_usb1)
i tried uninitialized the hardware ,but not possible
below is my code
so how to release the hardwar and i can init it at second time
Code: Select all
private void tbConnect_Click(object sender, EventArgs e)
{
if (InitUDS_Device() == true)
{
}
}
private void tbDisconnect_Click(object sender, EventArgs e)
{
var dt = DateTime.Now;
CloseUDS_Device();
}
private bool CloseUDS_Device()
{
UDSApi.Uninitialize(UDSApi.PUDS_USBBUS1);
PCANBasic.Uninitialize(PCANBasic.PCAN_USBBUS1);
return true;
}
private bool InitUDS_Device()
{
// TPUDSStatus result_uds;
try
{
TPUDSStatus result_uds;
result_uds = UDSApi.Initialize(UDSApi.PUDS_USBBUS1, TPUDSBaudrate.PUDS_BAUD_500K);
if (TPUDSStatus.PUDS_ERROR_OK != result_uds)
{
return false;
}
}
catch
{
return false;
}
return true;
}
Thanks!
Last edited by
K.Wagner on Fri 17. Nov 2023, 14:14, edited 1 time in total.
-
K.Wagner
- Software Development

- Posts: 1082
- Joined: Wed 22. Sep 2010, 13:36
Post
by K.Wagner » Fri 17. Nov 2023, 14:24
Hello,
ich you use PCAN-UDS for initializing a channel, do not use PCAN-Basic for uninitialize it. PCAN-UDS uses internally PCAN-Basic to do CAN communicaiton and so for initializeing and uninitalizing the channels. So please, do not use PCAN-Basic directly if you intention is to work with UDS.
Ken0711 wrote: ↑Fri 17. Nov 2023, 13:31
so how to release the hardwar and i can init it at second time
If you initialize an PCAN-UDS channel like this:
Code: Select all
UDSApi.Initialize(UDSApi.PUDS_USBBUS1, TPUDSBaudrate.PUDS_BAUD_500K);
then to uninitialize the same channel use the code like this:
Code: Select all
UDSApi.Uninitialize(UDSApi.PUDS_USBBUS1);
Nothing more is needed. After calling Uninitialize you are able to call Initialize again within PCAN-UDS, or using that channel with another API like PCAN-ISO-TP or PCAN-Basic.
Best regards,
Keneth
-
Ken0711
- Posts: 21
- Joined: Wed 19. Jul 2023, 03:04
Post
by Ken0711 » Fri 17. Nov 2023, 14:38
Hi,Wagner
There seems something wrong with init function,
I just wrote a simple code to init the device and the deinit it ,as shown the code
TPUDSStatus result;
result = UDSApi.Uninitialize(UDSApi.PUDS_USBBUS1);
result = UDSApi.Initialize(UDSApi.PUDS_USBBUS1, TPUDSBaudrate.PUDS_BAUD_500K);
still feedback already initialize,even through i deinit Ok ,the init again ,also feedback already initialize ,
as shown the last post ,i also tried the function UDSApi.Uninitialize(UDSApi.PUDS_USBBUS1);but not success
so i didn't know whether someplace need to setting ?
thanks!
-
K.Wagner
- Software Development

- Posts: 1082
- Joined: Wed 22. Sep 2010, 13:36
Post
by K.Wagner » Fri 17. Nov 2023, 14:50
Hello,
Ken0711 wrote: ↑Fri 17. Nov 2023, 14:38
There seems something wrong with init function,
Everything is OK with those functions. Those are plenty tested and used by a lot of people worldwide.
If when initializing you already got the message that the channel is already initialized, then it muss be something worng in your application. Probably the applicaiton is still running in the background and have connected the channel. You can check this in two ways:
- By using the PEAK-Settings app (control panel) in the section PCAN-BAsic API (see picture attached)
- By checking in the Windows Task Manager whether any of your applications is still active.
-
Attachments
-

- PEAK-Settings.JPG (47.19 KiB) Viewed 9091 times
Best regards,
Keneth
-
Ken0711
- Posts: 21
- Joined: Wed 19. Jul 2023, 03:04
Post
by Ken0711 » Fri 17. Nov 2023, 15:08
Hi Wagner ,
Thanks for your fast feedback !
By checking in the Windows Task Manager whether any of your applications is still active.
the APP still running in the task manager ,i have solved it !
you can close the topic !
Thanks Again !