Page 1 of 1
PCAN Initialize Failure
Posted: Fri 17. Nov 2023, 12:18
by Ken0711
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!
Re: PCAN Initialize Failure
Posted: Fri 17. Nov 2023, 13:24
by K.Wagner
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.
Re: PCAN Initialize Failure
Posted: Fri 17. Nov 2023, 13:31
by Ken0711
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!
Re: PCAN Initialize Failure
Posted: Fri 17. Nov 2023, 14:24
by K.Wagner
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.
Re: PCAN Initialize Failure
Posted: Fri 17. Nov 2023, 14:38
by Ken0711
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!
Re: PCAN Initialize Failure
Posted: Fri 17. Nov 2023, 14:50
by K.Wagner
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.
Re: PCAN Initialize Failure
Posted: Fri 17. Nov 2023, 15:08
by Ken0711
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 !
Re: PCAN Initialize Failure
Posted: Fri 17. Nov 2023, 15:26
by K.Wagner
Hello,
Please check the library versions you are using and udpate in case they are not up to date. You cans see the history of change here:
PCAN-UDS:
https://www.peak-system.com/PCAN-UDS-API.373.0.html
PCAN-ISO-TP:
https://www.peak-system.com/PCAN-ISO-TP-API.372.0.html
PCAN-Basic:
https://www.peak-system.com/PCAN-Basic.126.0.html
Closed!