mb2hal modbus function code 06
11 Jun 2020 17:17 #171150
by AndrewL
mb2hal modbus function code 06 was created by AndrewL
I have a mb2hal dilemma:
As far as I can tell, mb2hal doesn't support function code 06 - write to a single register. And I'm trying to write to device that doesn't support function code 16 - write to multiple registers (even if I set NELEMENTS=1). This is a RS-485 network
Does anyone know of a potential solution or workaround?
As far as I can tell, mb2hal doesn't support function code 06 - write to a single register. And I'm trying to write to device that doesn't support function code 16 - write to multiple registers (even if I set NELEMENTS=1). This is a RS-485 network
Does anyone know of a potential solution or workaround?
Please Log in or Create an account to join the conversation.
11 Jun 2020 17:57 #171158
by Grotius
Replied by Grotius on topic mb2hal modbus function code 06
#REQUIRED: You must specify either a "serial" or "tcp" link for the first transaction.
#Later transaction will use the previous transaction link if not specified.
LINK_TYPE=tcp
#if LINK_TYPE=tcp then REQUIRED (only 1st time): The Modbus slave device ip address.
#if LINK_TYPE=serial then IGNORED
TCP_IP=192.168.2.10
Maybe this solves it:
LINK_TYPE=serial
#Later transaction will use the previous transaction link if not specified.
LINK_TYPE=tcp
#if LINK_TYPE=tcp then REQUIRED (only 1st time): The Modbus slave device ip address.
#if LINK_TYPE=serial then IGNORED
TCP_IP=192.168.2.10
Maybe this solves it:
LINK_TYPE=serial
Please Log in or Create an account to join the conversation.
12 Jun 2020 19:50 #171301
by Bend
Replied by Bend on topic mb2hal modbus function code 06
There appears to be new code that supports function code 6: github.com/LinuxCNC/linuxcnc/pull/487/files
However, i have no clue how to compile it/merge it into linux cnc.
However, i have no clue how to compile it/merge it into linux cnc.
Please Log in or Create an account to join the conversation.
13 Jun 2020 12:30 #171417
by Grotius
Replied by Grotius on topic mb2hal modbus function code 06
Hi Bend,
Okey this is your workflow, attached some up to date files.
If you have a run in place installation, you do a "./rip-environment" command before "halcompile" command.
Use sudo before each command if you are not as root. For root type "su" enter.
Okey while i did a halcompile, i could not find modbus.h. So i located that file by a find command : "find . -name "modbus.h"
root@debian:/# find . -name "modbus.h"
Location found, oke this is nice :
./usr/include/modbus/modbus.h
I changed the mb2hal header file, so it stops complaining..
Line 17 and 18 now looks like :
//#include <modbus.h>
#include "/usr/include/modbus/modbus.h"
Then i did a halcompile again, if you have a rip install and are root :
root@debian:/home/user/linuxcnc/scripts# ./rip-environment halcompile --install /home/user/linuxcnc/src/hal/user_comps/mb2hal/mb2hal.c
Compiling realtime mb2hal.c
Linking mb2hal.so
cp mb2hal.so /home/user/linuxcnc/rtlib/
root@debian:/home/user/linuxcnc/scripts#
If you have no rip install and no root :
root@debian:/home/user/linuxcnc/scripts# sudo halcompile --install /home/user/linuxcnc/src/hal/user_comps/mb2hal
If you have no rip and root, problably :
root@debian:/home/user/linuxcnc/scripts# ./halcompile --install /home/user/linuxcnc/src/hal/user_comps/mb2hal
or
root@debian:/home/user/linuxcnc/scripts# halcompile --install /home/user/linuxcnc/src/hal/user_comps/mb2hal
Here you go :
Okey this is your workflow, attached some up to date files.
If you have a run in place installation, you do a "./rip-environment" command before "halcompile" command.
Use sudo before each command if you are not as root. For root type "su" enter.
Okey while i did a halcompile, i could not find modbus.h. So i located that file by a find command : "find . -name "modbus.h"
root@debian:/# find . -name "modbus.h"
Location found, oke this is nice :
./usr/include/modbus/modbus.h
I changed the mb2hal header file, so it stops complaining..
Line 17 and 18 now looks like :
//#include <modbus.h>
#include "/usr/include/modbus/modbus.h"
Then i did a halcompile again, if you have a rip install and are root :
root@debian:/home/user/linuxcnc/scripts# ./rip-environment halcompile --install /home/user/linuxcnc/src/hal/user_comps/mb2hal/mb2hal.c
Compiling realtime mb2hal.c
Linking mb2hal.so
cp mb2hal.so /home/user/linuxcnc/rtlib/
root@debian:/home/user/linuxcnc/scripts#
If you have no rip install and no root :
root@debian:/home/user/linuxcnc/scripts# sudo halcompile --install /home/user/linuxcnc/src/hal/user_comps/mb2hal
If you have no rip and root, problably :
root@debian:/home/user/linuxcnc/scripts# ./halcompile --install /home/user/linuxcnc/src/hal/user_comps/mb2hal
or
root@debian:/home/user/linuxcnc/scripts# halcompile --install /home/user/linuxcnc/src/hal/user_comps/mb2hal
Here you go :
The following user(s) said Thank You: Bend
Please Log in or Create an account to join the conversation.
13 Jun 2020 12:57 #171425
by Grotius
Replied by Grotius on topic mb2hal modbus function code 06
A second way,
maybe a more elegant way is to copy these attached files into the mb2hal directory, except the file with .txt extension.
Now it can run on any pc, everywhere without static linking.
Then open terminal, replace your directory structure, use sudo instead, or remove ./rip-environment :
root@debian:/home/user/linuxcnc/scripts# ./rip-environment halcompile --install /home/user/linuxcnc/src/hal/user_comps/mb2hal/mb2hal.c
Compiling realtime mb2hal.c
Linking mb2hal.so
cp mb2hal.so /home/user/linuxcnc/rtlib/
root@debian:/home/user/linuxcnc/scripts#
If you wanna save time. Rename the mb2hal.txt to mb2hal.so and replace it in the linuxcnc/rtlib directory.
Compiled for 64 bits, if it matters.
maybe a more elegant way is to copy these attached files into the mb2hal directory, except the file with .txt extension.
Now it can run on any pc, everywhere without static linking.
Then open terminal, replace your directory structure, use sudo instead, or remove ./rip-environment :
root@debian:/home/user/linuxcnc/scripts# ./rip-environment halcompile --install /home/user/linuxcnc/src/hal/user_comps/mb2hal/mb2hal.c
Compiling realtime mb2hal.c
Linking mb2hal.so
cp mb2hal.so /home/user/linuxcnc/rtlib/
root@debian:/home/user/linuxcnc/scripts#
If you wanna save time. Rename the mb2hal.txt to mb2hal.so and replace it in the linuxcnc/rtlib directory.
Compiled for 64 bits, if it matters.
Please Log in or Create an account to join the conversation.
Time to create page: 0.087 seconds