Install python_devel:

cd /usr/include/python2.7
wget -O  python_devel.tar.gz https://www.dropbox.com/s/z49hrigv3umaaj8/python_devel.tar.gz?dl=0 --no-check-certificate
tar -zxvf python_devel.tar.gz 
rm python_devel.tar.gz

 

Download crcmod source:

cd /mnt/sda1
wget https://pypi.python.org/packages/source/c/crcmod/crcmod-1.7.tar.gz --no-check-certificate
tar -zxvf  crcmod-1.7.tar.gz
cd crcmod-1.7
python setup.py build
gcc -fno-strict-aliasing -Os -pipe \
-mips32r2 -mtune=mips32r2 -fno-caller-saves  \
-Wno-error=unused-but-set-variable -msoft-float -DNDEBUG -Os \
-fPIC -I/usr/include/python2.7 \
-c python2/src/_crcfunext.c -o build/temp.linux-mips-2.7/python2/src/_crcfunext.o
gcc -pthread -shared build/temp.linux-mips-2.7/python2/src/_crcfunext.o \
-L/usr/lib  -o build/lib.linux-mips-2.7/crcmod/_crcfunext.so
python setup.py install

 

 

 

Write comment (0 Comments)

nano  /mnt/sda1/usbreset3.c
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <linux/usbdevice_fs.h>

int main(int argc, char **argv)
{
	const char *filename;
	int fd;
	int rc;

	if (argc != 2) {
		fprintf(stderr, "Usage: usbreset device-filename\n");
		return 1;
	}
	filename = argv[1];

	fd = open(filename, O_WRONLY);
	if (fd < 0) {
		perror("Error opening output file");
		return 1;
	}

	printf("Resetting USB device %s\n", filename);
	rc = ioctl(fd, USBDEVFS_RESET, 0);
	if (rc < 0) {
		perror("Error in ioctl");
		return 1;
	}
	printf("Reset successful\n");

	close(fd);
	return 0;
}
gcc -o usbreset3  /mnt/sda1/usbreset3.c
chmod 755 usbreset3
root@Arduino:~# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 058f:6254 Alcor Micro Corp. USB Hub
Bus 001 Device 003: ID 0424:2507 Standard Microsystems Corp. hub
Bus 001 Device 004: ID 058f:6366 Alcor Micro Corp. Multi Flash Reader
Bus 001 Device 005: ID 046d:0829 Logitech, Inc.

Reset logitech camera:

root@Arduino:~# /mnt/sda1/usbreset3 /dev/bus/usb/001/005
Resetting USB device /dev/bus/usb/001/005
Reset successful

If reset root hub will crash machine!

Download pre-compile usbreset3:

wget -O usbreset3 https://www.dropbox.com/s/xlnkut2jpcy7evj/usbreset3?dl=0 --no-check-certificate

 

 

Write comment (0 Comments)

To complete example, here is hello world C example.

nano hello.c

//C hello world example
#include <stdio.h>
 
int main()
{
  printf("Hello world\n");
  return 0;
}

gcc -Wall hello.c -o hello

./hello
Hello world

 

Write comment (0 Comments)

nano arbitrary-baud.c
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <linux/termios.h>

int ioctl(int d, int request, ...);

int main(int argc, char *argv[])
{
 struct termios2 t;
 int fd,baud;

 if (argc != 3)
   {
     fprintf(stderr,"usage: %s <device> <baud>\n", argv[0]);
     return 1;
   }

 fd = open(argv[1], O_RDWR | O_NOCTTY | O_NDELAY);

 if (fd == -1)
     {
       fprintf(stderr, "error opening %s: %s", argv[1], strerror(errno));
       return 2;
     }

 baud = atoi(argv[2]);

 if (ioctl(fd, TCGETS2, &t))
   {
     perror("TCGETS2");
     return 3;
   }

 t.c_cflag &= ~CBAUD;
 t.c_cflag |= BOTHER;
 t.c_ispeed = baud;
 t.c_ospeed = baud;

 if (ioctl(fd, TCSETS2, &t))
   {
     perror("TCSETS2");
     return 4;
   }

 if (ioctl(fd, TCGETS2, &t))
   {
     perror("TCGETS2");
     return 5;
   }

 printf("actual speed reported %d\n", t.c_ospeed);
 return 0;
}
gcc -o arbitrary-baud arbitrary-baud.c

Download  Yun excutable here:

https://www.dropbox.com/s/6sm82bhxpj8voor/arbitrary-baud?dl=0

 

Write comment (0 Comments)

Subcategories

Expand the Storage at Yun

Languages Supported by Yun

Backup and Recover

Network and Yun

Hardware & Yun

OpenWrt-SDK & Yun