CAN/en: различия между версиями

Новая страница: «For more information see the «AmadeuS» wiki article «[http://www.armadeus.com/wiki/index.php?title=CAN_bus_Linux_driver CAN bus Linux driver]».»
(Новая страница: «==== Via web interface ==== To configure via the web interface, you need to update the <code>wb-mqtt-confed</code> package to version 1.2.3+»)
(Новая страница: «For more information see the «AmadeuS» wiki article «[http://www.armadeus.com/wiki/index.php?title=CAN_bus_Linux_driver CAN bus Linux driver]».»)
Метки: правка с мобильного устройства правка из мобильной версии
 
(не показано 7 промежуточных версий этого же участника)
Строка 8: Строка 8:
To configure via the web interface, you need to update the <code>wb-mqtt-confed</code> package to version 1.2.3+
To configure via the web interface, you need to update the <code>wb-mqtt-confed</code> package to version 1.2.3+


Действия происходят в разделе '''Configs''' веб-интерфейса:
Actions take place in the '''Configs''' section of the web-interface:
# На вкладке '''Network Interfaces''' добавьте новый интерфейс <code>can0</code> (см. скриншот). Нажмите кнопку '''Save'''.
# On the '''Network Interfaces''' tab, add a new interface <code>can0</code> (see screenshot). Click the '''Save''' button.
# Переключите порт <code>RS-485/CAN</code> в режим CAN: на вкладке '''Hardware Modules Configuration''' выберите настройки '''RS485-2/CAN interface config''', выберите в поле '''Module type''' «CAN interface» и нажмите кнопку '''Save'''.
# Switch the <code>RS-485/CAN</code> port to CAN mode: on the '''Hardware Modules Configuration''' tab, select the settings '''RS485-2/CAN interface config''', select in the '''Module type''' «CAN interface» and click the '''Save''' button.


CAN-интерфейс будет подниматься сам при:
The CAN interface will rise by itself when:
* загрузке системы — за это отвечает сервис <code>wb-hwconf-manager</code>,
* system boot - service <code>wb-hwconf-manager</code> is responsible for this,
* смене режима порта RS-485/2 в «CAN».
* change the RS-485/2 port mode to «CAN».


==== Стандартными средствами linux (автоматически) ====
==== Using standard linux tools (automatically) ====
Раздел '''Network Interfaces''' веб-интерфейса — это обёртка вокруг файла <code>/etc/network/interfaces</code>, поэтому настройку CAN можно произвести с помощью службы управления сетями ОС debian. Для этого нужно:
The '''Network Interfaces''' section of the web interface is a wrapper around the <code>/etc/network/interfaces</code> file, so CAN configuration can be done using the debian network management service. For this you need:
# Добавить в <code>/etc/network/interfaces</code> запись вида:
# Add to <code>/etc/network/interfaces</code> an entry like this:
#:<syntaxhighlight lang="bash">
#:<syntaxhighlight lang="bash">
allow-hotplug can0
allow-hotplug can0
Строка 24: Строка 24:
bitrate 125000
bitrate 125000
</syntaxhighlight>
</syntaxhighlight>
# Переключить порт RS-485-2 в режим CAN
# Switch RS-485-2 port to CAN mode
Получим результат, аналогичный настройке через веб-интерфейс.
We will get a result similar to setting through the web-interface.


==== Стандартными средствами linux (вручную) ====
==== Using standard linux tools (manually) ====


После переключения порта в режим CAN, нужно выполнить:
After switching the port to CAN mode, you need to do:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
ip link set can0 up type can bitrate 125000
ip link set can0 up type can bitrate 125000
</syntaxhighlight>
</syntaxhighlight>


== Работа с CAN ==
== Working with CAN ==


Утилиты <code>cansend</code> и <code>candump</code> есть в стандартном наборе ПО контроллера. Если по каким-то причинам их нет, можно поставить пакет <code>can-utils</code>:
The <code>cansend</code> and <code>candump</code> utilities are included in the controller's standard software package. If for some reason they are not there, you can install the <code>can-utils</code> package:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
apt update && apt install can-utils
apt update && apt install can-utils
</syntaxhighlight>
</syntaxhighlight>


Примеры команд:
Command examples:
* Отправка четырех байт c адресом 123:
* Sending four bytes with address 123:
*:<syntaxhighlight lang="bash">
*:<syntaxhighlight lang="bash">
cansend can0 123#DEADBEEF
cansend can0 123#DEADBEEF
</syntaxhighlight>
</syntaxhighlight>


* Показывать входящие пакеты:
* Show incoming packets:
*:<syntaxhighlight lang="bash">
*:<syntaxhighlight lang="bash">
candump can0
candump can0
</syntaxhighlight>
</syntaxhighlight>


* Показать статистику:
* Show statistics:
*:<syntaxhighlight lang="bash">
*:<syntaxhighlight lang="bash">
cat /proc/net/can/stats
cat /proc/net/can/stats
Строка 58: Строка 58:




Обратите внимание, что в случае проблем на шине (нет терминатора, нет принимающего устройства, короткое замыкание), контроллер может прекратить работу.
Please note that in case of problems on the bus (no terminator, no receiving device, short circuit), the controller may stop working.
Для того чтобы начать работу вновь, выполните:  
To start working again, run:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
ifconfig can0 down && ip link set can0 up type can bitrate 125000
ifconfig can0 down && ip link set can0 up type can bitrate 125000
</syntaxhighlight>
</syntaxhighlight>


Больше информации смотрите в вики проекта «AmadeuS», статья «[http://www.armadeus.com/wiki/index.php?title=CAN_bus_Linux_driver CAN bus Linux driver]».
For more information see the «AmadeuS» wiki article «[http://www.armadeus.com/wiki/index.php?title=CAN_bus_Linux_driver CAN bus Linux driver]».
translator, wb_editors
4285

правок