CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Sun Oct 20, 2019 3:57 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 16 posts ]  Go to page 1 2 Next
Author Message
PostPosted: Tue Mar 12, 2019 7:22 am 
Offline

Joined: Mon Apr 25, 2011 1:37 pm
Posts: 22
Hello!
There are no problems with the physical interface can0, everything works.
We want to use the virtual can (vcan) interface in the Beaglebone Black controller from the CoDeSys environment, but it does not work.

I activate the virtual can in the controller with the following commands:
 $ modprobe vcan
 $ sudo ip link add dev can2 type vcan
 $ sudo ip link set up can2

Through ifconfig I see that this interface appeared in the system.
Utilities can-utils work with it without any problems.

BUT, if you add this interface number (2) to the can bus in the CoDeSys project, then after loading the project into the controller, an error appears in the log that the device could not be configured.

What could be the reason?

I tried to remove the bitrate setting from the file rts_set_baud.sh because vcan does not support this setting, but it did not help.


Top
   
PostPosted: Sat Mar 16, 2019 10:33 am 
Offline

Joined: Mon Apr 25, 2011 1:37 pm
Posts: 22
No one can help? I also wrote help on the store, also silence. Maybe the manufacturer is not interested in selling?


Top
   
PostPosted: Sat Mar 16, 2019 7:02 pm 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 3495
not sure if vcan is supported by CODESYS.. don't think so.
Let me check.
BR
Edwin


Top
   
PostPosted: Wed Mar 20, 2019 7:27 am 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 3495
Hi,
what do you want to archive with this virtual CAN / vcan?
Maybe you need to explain a little more in detail.

BR
Edwin


Top
   
PostPosted: Wed Mar 20, 2019 12:19 pm 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 3495
Hi,
you could give the following solution a try (wihout guarantee that this will work)

[CmpSocketCanDrv]
ScriptPath=/opt/codesys/scripts/
ScriptName=rts_set_baud.sh
InterfaceName=vcan

not sure, if it will work (did not try) but sure is either vcan will work or the real interface not both at the same time
I guess.

BR
Edwin


Top
   
PostPosted: Thu Mar 21, 2019 5:51 am 
Offline

Joined: Mon Apr 25, 2011 1:37 pm
Posts: 22
Thanks, Edwin!
Let's try today or tomorrow.
The reason for using vcan is an implementation of automatic switching between two physical can interfaces, unfortunately the driver built into CoDeSys cannot do this. Correct if I'm wrong.


Top
   
PostPosted: Fri Mar 22, 2019 2:26 pm 
Offline

Joined: Mon Apr 25, 2011 1:37 pm
Posts: 22
Hi,
Using the "InterfaceName = vcan" parameter does not help,
but this setting is somehow applied runtime because after that the physical can interface also stops working.
Attachment:
66.jpg

Record in CoDeSys log
Attachment:
44.jpg
and the output of the command "ifconfig vcan2".
Attachment:
55.jpg



Using the InterfaceName = vcan parameter does not help, but this setting is somehow applied runtime because after that the physical can interface also stops working. An entry in the CoDeSys log.
The output of the command "ifconfig vcan2" in the attachment.

I noticed that even in normal mode, the setting "Baudrate = Use current setting" does not work
Attachment:
88.jpg
Attachment:
77-can2-error.jpg
(and when setting a specific speed it works)
Attachment:
77-can0-ok.jpg


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Thu Mar 28, 2019 3:18 pm 
Offline

Joined: Mon Apr 25, 2011 1:37 pm
Posts: 22
Hello!
Until now, there is no solution.
And the ticket on store.codesys.com is closed with redirection to this thread in the forum: (
Attachment:
ticket_close.jpg

Are there any other ideas that you can try other than "InterfaceName = vcan"?
The test bench is on and available at any time.


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Fri Mar 29, 2019 7:08 am 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 3495
come on,
this is not good stile to post here screenshots from store requests!
Need some time....
BR
Edwin


Top
   
PostPosted: Fri Mar 29, 2019 11:36 am 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 3495
Hi,
at the moment it is not possible to mix it up and use vcan and real can at the same time in CODESYS.
If you need this this need to be done by a improvement tracking entry ….!

BR
Edwin


Top
   
PostPosted: Thu Apr 04, 2019 6:28 am 
Offline

Joined: Mon Apr 25, 2011 1:37 pm
Posts: 22
Hi!
NOT! I don't need to use real and virtual can at the SAME TIME! I need ONLY a virtual can! And the string "InterfaceName = vcan" does not work! Help me please! Already so much time there is no solution :(


Top
   
PostPosted: Thu Apr 04, 2019 3:55 pm 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 3495
I see no workaround...
it is possible to use CAN ( as interface name) but it stops after 2 interfaces... (hard coded)
BR
Edwin


Top
   
PostPosted: Thu Apr 11, 2019 8:21 am 
Offline

Joined: Mon Apr 25, 2011 1:37 pm
Posts: 22
Hello, Edwin!

Excuse me, really, the "InterfaceName = vcan" setting works!
The problem was that the number of CAN interfaces used by CoDeSys should be no more than 2.
Now there is another problem, how to use the vcan interface?
The Candump utility program does not see the packets that the CoDeSys sends to the CAN bus via the vcan interface.

For the physical CAN interface, this is not a problem. You can view the packets on the bus using another device, and for virtual CAN I did not find a suitable solution.

Forwarding packets with socat or cangw utility programs
work ONLY to receive packets in the direction of CoDeSys

socat INTERFACE: can0, pf = 29, type = 3, prototype = 1 INTERFACE: vcan0, pf = 29, type = 3, prototype = 1

or via cangw

cangw -A -s can0 -d vcan0
cangw -A -s vcan0 -d can0

Thus, packet transmission in the direction "CoDeSys -> vcan0-> can0-> physical CAN device" does not work
But it works in the opposite direction.

How to solve this problem?

Most likely the reason is that when you open a socket in the Canopen CoDeSys driver, loopback mode is disabled:
 
int loopback = 0;
       if (setsockopt (s_fd_write [byNet], SOL_CAN_RAW, CAN_RAW_LOOPBACK, & loopback, sizeof (loopback))) {
               DEBUGP ("setsockopt (CAN_RAW_LOOPBACK):% s", strerror (errno));
       }

If this is true, then how was the virtual can interface supposed to be used? After all, virtual can works only through loopback (correct, if I'm wrong).


Top
   
PostPosted: Tue Apr 23, 2019 5:10 am 
Offline

Joined: Mon Apr 25, 2011 1:37 pm
Posts: 22
It took almost 2 weeks, but no answer!
At the same time, the ticket on store.codesys.com is closed!
Help me please!!!


Top
   
PostPosted: Tue Apr 23, 2019 3:33 pm 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 3495
Hi,
give this a try:

[CmpSocketCanDrv]
Loopback=1

BR
Edwin


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 16 posts ]  Go to page 1 2 Next

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited