Hello,
i tried to compile a file to use an Arduino Mega as io expansion
(https://forum.linuxcnc.org/18-computer/23166-arduino-i-o-with-linuxcnc?limitstart=0)
but it does not seem to compile the file.
i do
cd /home/machinekit/Desktop
sudo comp --install serialreceive.comp
and this is what it does (ignore the Clock skew, i rebooted the BBB to get
the message again but wasnt connected to the internet but before i rebooted
i was connected to the internet and tried to compile, so there was no Clock
skew warning):
machinekit@beaglebone:~$ cd /home/machinekit/Desktop
machinekit@beaglebone:~/Desktop$ sudo comp --install serialreceive.comp
make: Warning: File `/usr/share/linuxcnc/Makefile.inc' has modification
time 3e+07 s in the future
arm-linux-gnueabihf-gcc -I. -pthread -DTHREAD_FLAVOR_ID=0 -DRTAPI
-D_GNU_SOURCE -D_FORTIFY_SOURCE=0 -D__MODULE__ -I/usr/include/linuxcnc
-fPIC -g -funwind-tables -I/home/machinekit/Desktop
-I/home/machinekit/Desktop -URTAPI -U__MODULE__ -DULAPI -Os -o
serialreceive /tmp/tmpoau6XB/serialreceive.c -Wl,-rpath,/usr/lib -L/usr/lib
-llinuxcnchal
make: warning: Clock skew detected. Your build may be incomplete.
machinekit@beaglebone:~/Desktop$
so i added "loadrt serialreceive" to my hal file and when i start my
machine it gives me an error:
machinekit@beaglebone:~$ linuxcnc
MACHINEKIT - 0.1
Machine configuration directory is
'/home/machinekit/machinekit/configs/ARM.BeagleBone.CRAMPS'
Machine configuration file is 'CRAMPS.ini'
Starting Machinekit...
io started
halcmd loadusr io started
cape-universal overlay found
Loading cape-bone-iio overlay
stat: No such file or directory
CRAMPS.hal:23: insmod failed, returned -1:
do_load_cmd: dlopen: serialreceive.so: cannot open shared object file: No
such file or directory
rpath=/usr/lib/linuxcnc/xenomai
See /var/log/linuxcnc.log for more information.
Shutting down and cleaning up Machinekit...
exiting HAL component Therm
Cleanup done
Machinekit terminated with an error. You can find more information in the
log:
/home/machinekit/linuxcnc_debug.txt
and
/home/machinekit/linuxcnc_print.txt
as well as in the output of the shell command 'dmesg' and in the terminal
machinekit@beaglebone:~$
so i looked in "/usr/lib/linuxcnc/xenomai" and there was no file called
"serialreceive.so"
what is possibly going wrong? Can someone compile the file for me and
upload it here for others who also try to use an Arduino as io expander?
thanks for any help
--
website: http://www.machinekit.io blog: http://blog.machinekit.io github:
https://github.com/machinekit
---
You received this message because you are subscribed to the Google Groups
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.
//serialreceive.comp
component serialreceive "Receiving 32 bits data from arduino";
pin out bit bit-##[32] = false "Output bits";
option singleton yes;
option userspace yes;
author "ArcEye [email protected]";
license "GPL";
;;
#include <stdio.h> /* Standard input/output definitions */
#include <stdlib.h>
#include <stdint.h> /* Standard types */
#include <string.h> /* String function definitions */
#include <unistd.h> /* UNIX standard function definitions */
#include <fcntl.h> /* File control definitions */
#include <errno.h> /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */
#include <sys/ioctl.h>
#define BAUDRATE B9600
#define DEVICE "/dev/ttyACM0"
#define _POSIX_SOURCE 1 /* POSIX compliant source */
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) :
bitClear(value, bit))
int serialport_init();
struct termios toptions;; // port setup
void user_mainloop(void)
{
int c, x, y, z;
char ch;
int fd = serialport_init();
while (fd != -1)
{
usleep(1000000);
FOR_ALL_INSTS()
{
z = 0;
for(x = 0; x < 4; x++) // 4 packets 8 bits
{
read(fd,&ch,1);
for(y = 0; y < 8 ; y++) bit(z++) = bitRead(ch, y);
}
// test - to show that bits were written
// comment out next 3 lines when using for real
//for(x = 0; x < 32; x++)
// fprintf(stderr,"%d",bit(x));
//fprintf(stderr,"\n");
}
}
close(fd);
exit(0);
}
//######################################################################
int serialport_init()
{
int fd;
fd = open(DEVICE, O_RDWR | O_NOCTTY | O_NDELAY);
if (fd == -1)
{
perror("init_serialport: Unable to open port ");
return -1;
}
if (tcgetattr(fd, &toptions) < 0)
{
perror("init_serialport: Couldn't get term attributes");
return -1;
}
speed_t brate = BAUDRATE;
cfsetispeed(&toptions, brate);
cfsetospeed(&toptions, brate);
// 8N1
toptions.c_cflag &= ~PARENB;
toptions.c_cflag &= ~CSTOPB;
toptions.c_cflag &= ~CSIZE;
toptions.c_cflag |= CS8;
// no flow control
toptions.c_cflag &= ~CRTSCTS;
toptions.c_cflag |= CREAD | CLOCAL; // turn on READ & ignore ctrl lines
toptions.c_iflag &= ~(IXON | IXOFF | IXANY); // turn off s/w flow ctrl
toptions.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); // make raw
toptions.c_oflag &= ~OPOST; // make raw
toptions.c_cc[VMIN] = 0;
toptions.c_cc[VTIME] = 20;
if( tcsetattr(fd, TCSANOW, &toptions) < 0)
{
perror("init_serialport: Couldn't set term attributes");
return -1;
}
return fd;
}