CAN communication error in robot frame work

Tool: Vs code
language : Python
Robot frame work : 1.13.0

Iam using PCANBasic.py file from PEAK CAN system
to initialize CAN
PCANBasic.Initialize(PCAN_USBBUS1,PCAN_BAUD_500K,0,0,0)

will be initialize can 1 channel with 500k baudrate can communication working and able to get communication fine.

when iam calling same function in robot frame work using start process api to run in background but iam getting can init error
initialization fails and giving code status 67108864 (0x4000000)

Sorry no experience on this particular library.

The error seems related to the device being already in use somewhere else.

https://forum.peak-system.com/viewtopic.php?t=3053

So:

  • did you close the previous connection properly?
  • does it work better if you try using robot framework first, after rebooting your test host machine?
  • could it be that robot framework instantiates your connection several times rather than once (check library scope is TEST by default)?

Hello

Thank you for reply

Even after first run after reboot, it is giving same error

I closed previous process connection and Verified with PEAK SETTINGS on running cahnnels use

When iam calling direct function it is initializing and running

but i need it to run in background so

Iam calling it with api start process which will run the function in background

With this start process iam getting can init error

start process Python -u SgxAts.py stdout= output.log stderr= error.log

SgxAts.py contains function which has infinite loop which initialize and communicate with CAN

Please let me knoe If there any difference calling function directly in robot frame work and calling with satrt process

Thank you

Hello, I would not know what are the difference between running SgxAts.py directly and running it through RobotFramework Start Process keyword…

Have you tried running SgxAts.py using subprocess from another python script? Maybe it already does not work this way, and the issue would not be related to RobotFramework.

Perhaps the python environment or the user permission (admin vs regular user) are not the same when you run SgxAts.py directly or through RobotFramework ? Which could deny access to some resources.

You may have more chances at getting an answer if you ask on the RobotFramework Slack. You could post in the #python channel, then forward the question to the #embedded to attract more attention.