2013-09-06

AVR links

How to get started with Eclipse and AVR

UBUNTU_MENUPROXY= ./eclipse




Тахометр на Attiny.Продолжаем знакомство с AVR.

AVR ASM:
http://we.easyelectronics.ru/AVR/assemblernye-vstavki-v-avr-gcc.html http://embedderslife.wordpress.com/2012/02/19/avr-gcc-asm-and-c/
http://www-leland.stanford.edu/class/ee281/projects/aut2002/yingzong-mouse/media/GCCAVRInlAsmCB.pdf

2013-08-30

Android USB HOWTO


Manual:
http://developer.android.com/guide/topics/connectivity/usb/index.html
http://developer.android.com/reference/android/hardware/usb/UsbManager.html 

http://developer.android.com/tools/adk/index.html 
http://developer.android.com/tools/adk/adk2.html
http://source.android.com/accessories/custom.html

Example:

http://code.google.com/p/usb-serial-for-android/ 
http://code.google.com/p/usb-serial-for-android/source/browse/#git%2FUsbSerialExamples
Не так давно Google открыл API для работы Android устройств с USB. Сегодня пришло время пощупать что же это такое и узнать какие возможности нам открываются.http://habrahabr.ru/post/123361/



Discussion:
http://stackoverflow.com/questions/3803871/android-apps-communicating-with-a-device-plugged-in-the-usb-port
http://stackoverflow.com/questions/11337852/android-usb-application

Одной из самых интересных новинок, представленных на Google I/O 2011, можно считать анонс полноценной работы Android устройств с USB.
Новый Android поддерживает два USB режима — хост (Host mode) и устройство (Accessory mode).http://habrahabr.ru/post/119208/

http://habrahabr.ru/post/181996/
Собираем CarPC на Android: недостроенный долгострой

Android эмулятор Genimotion

Java USB HOWTO


?jUSB and JSR 80 but both seem to be dead projects (at least for Windows).

we had to build our own custom C wrappers to the USB drivers and communicate with them through JNI


libusb-win32 requires you to install their generic driver, which then makes a USB device available to you. I'm not sure that it's possible to do driver-less access of an USB device unless the device belongs to one of several standard classes (storage and HID, in particular).
There is a Java wrapper for libusb-win32 which might work for you. I haven't used it myself, though.


The fastest and easiest way is to hack some native code :) I wrote a small wrapper for HID devices that enabled my Java applications to read data from CalComp digitizers, so it's definitely doable and not too hard. The bad thing is that my work is still proprietary code owned by my former employer, so for legal reasons I can't release that as open-source -- yet.
The good thing is that you can get a flying start with the HID example code from the Microsoft DDK :)

See the Libusb java binding on github
alternativly there is usb4java from which The low-level part is based on the native libusb 0.1


http://stackoverflow.com/questions/3803871/android-apps-communicating-with-a-device-plugged-in-the-usb-port
https://today.java.net/pub/a/today/2006/07/06/java-and-usb.html
http://www.ibm.com/developerworks/library/j-usb/index.html 

The only USB API I could find for Windows is here. Seems as if it has limited functionality, but it might suit your needs. A more complete UNIX API is also available.
ETA: Found a link to the official Java USB implementation, but looks like the windows version is still in alpha.
The above link to javax-usb.org is dead. However I found these two: javax.usb (This seems to be the official one) and javax-usb-libusb1

The native code API I referred to was the Windows DDK, i.e. the Driver Development Kit. The modern version seem to be called Windows Driver Kit, so google for Windows WDK :) There should be a few C samples on how to communicate with USB devices, and it should be pretty straightforward to write a JNI wrapper from those.

found this page that explains how to perform a communication between a microcontroller and a java application: http://javausbapi.blogspot.com/

http://www.math.ucla.edu/~anderson/JAVAclass/JavaInterface/JavaInterface.html 

2013-08-29

AVR USB HOWTO

How to compile a C program with libusbx-1.0 support

gcc cmdClient.c -ocmdClient -O -Wall -I/usr/local/include/libusb-1.0 -L/usr/local/lib -lusb-1.0 -ludev -lrt
[root@localhost cmdClient]# ./cmdClient  
./cmdClient: symbol lookup error: ./cmdClient: undefined symbol: libusb_get_port_numbers
########## The first thing you want to check is whether your program is actually using the libusbx library or libusb. If libusb is installed as a system library and hasn't been replaced, there's a good chance your application is using libusb rather than libusbx, and if it does, you will get errors for the function calls that are only present in libusbx. You may want to try to call libusb_get_version() and print the data (see the end of examples/xusb.c for how to do that), to confirm that you are actually using libusbx 1.0.15 and not libusb. ############

gcc cmdClient.c -ocmdClient -O -Wall -I./libusb -L/usr/local/lib -lusb-1.0 ./cmdClient
./cmdClient: error while loading shared libraries: libusb-1.0.so.0: cannot open shared object file: No such file or directory find /usr -name "*libusb-1.0.so.0*" /usr/local/lib/libusb-1.0.so.0 /usr/local/lib/libusb-1.0.so.0.1.0

Solution 1:
gcc cmdClient.c -ocmdClient -O -Wall -I/usr/local/include/libusb-1.0 -L/usr/local/lib -lusb-1.0 -Wl,-rpath -Wl,/usr/local/lib

[root@localhost cmdClient]# ./cmdClient
Using libusbx v1.0.16.10774

Solution 2:
strace ./cmdClient

open("/usr/lib/libusb-1.0.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)

ln -s /usr/local/lib/libusb-1.0.so.0 /usr/lib/libusb-1.0.so.0

gcc cmdClient.c -ocmdClient -O -Wall -I/usr/local/include/libusb-1.0 -L/usr/local/lib -lusb-1.0
or
gcc cmdClient.c -ocmdClient -O -Wall -I./libusb -L./libusb -lusb-1.0

[root@localhost cmdClient]# ./cmdClient
Using libusbx v1.0.16.10774


###########################
linux tools:
file  
locate
ldd /usr/local/lib/libusb-1.0.so.0

http://sourceforge.net/projects/libusbx/
http://libusbx.sourceforge.net/api-1.0/modules.html
##############################
Final result:

#include stdio.h
#include stdint.h
#include stdlib.h
#include string.h
#include stdarg.h
#include unistd.h

#include "libusb.h"

uint16_t VID, PID;


static int test_device_on_off(int i_usb_led_on)
{   
    libusb_device_handle *handle;

    int i, r;

    printf("Opening device %04X:%04X...\n", VID, PID);
    handle = libusb_open_device_with_vid_pid(NULL, VID, PID);

    if (handle == NULL) {
        printf("  Failed.\n");
        return -1;
    }

    unsigned char data[256];
    r = libusb_control_transfer(handle,LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE, i_usb_led_on, 0, 0, (unsigned char *)data,sizeof(data), 5000);
    if (r < 0) {
        printf("F0 error %d\n", r);

    }
    if ((unsigned int) r < sizeof(data)) {
        printf( "short read (%d)\n", r);

    }

    printf("F0 data:");
    for (i = 0; i < sizeof(data); i++)
        printf("%02x ", data[i]);
    printf("\n");

    printf("Closing device...\n");
    libusb_close(handle);
}

int main(void)
{
    const struct libusb_version* version;
    int r;

    // Default to generic, expecting VID:PID
    VID = 0x16c0;
    PID = 0x05dc;

    version = libusb_get_version();
    printf("Using libusbx v%d.%d.%d.%d\n\n", version->major, version->minor, version->micro, version->nano);
    r = libusb_init(NULL);
    if (r < 0)
        return r;

    libusb_set_debug(NULL, 0?LIBUSB_LOG_LEVEL_DEBUG:LIBUSB_LOG_LEVEL_INFO);

    usleep(500000);
    test_device_on_off(0);
    usleep(500000);
    test_device_on_off(1);

    libusb_exit(NULL);
    return 0;
}


http://we.easyelectronics.ru/electro-and-pc/usb-dlya-avr-chast-1-vvodnaya.html
http://codeandlife.com/2012/01/22/avr-attiny-usb-tutorial-part-1/

##########################################################

avrdude -P /dev/ttyACM0 -p m8 -c avr910 -U flash:r:flash.hex:i

http://www.rogerclark.net/updating-firmware-on-usbasp-bought-from-ebay/
http://habrahabr.ru/post/208470/ Нестандартное использование USBasp
http://rootadmin.livejournal.com/10824.html Программатор AVR910 под Linux

http://www.gaw.ru/html.cgi/txt/app/micros/avr/AVR309.htm

2011-04-13

Linux

sudo su -
stty -F /dev/ttyUSB0 9600 cs8 -cstopb -parenb -icanon min 1 time 1
while true; do
        cat -v < /dev/ttyUSB0
done


В свежепроинсталлированой Fedora Linux не стартует сеть:

system-config-network-tui
system-config-firewall

1) dhclient eth0
2) chkconfig --list networking
chkconfig --list networking on
3)/etc/sysconfig/network-scripts/ifcfg-eth0:
ONBOOT=yes

virtualbox issue under Fedora 12:
sudo rmmod kvm-intel


Bluetooth:
sdptool browse local
sdptool add --channel=22 SP
sudo rfcomm listen /dev/rfcomm0 22  
cat /dev/rfcomm0
echo 'asdf' > /dev/rfcomm0 
echo -en '\xF4\x57\x01\x00\xB4\xF4\x92\x01\x07\x41\x00\x00\x00\x80\x81\x61\xF5\xF7\xFE\x19\x00\x69\x00\x00\xD8\x3F\x81\x79\x80\x00\x09\x5A\x5A\x00\x29\x19\x3B\x23\x00\x00\x00\x00\x20\x00\x04\x2A\x5B\x80\x00\x00\xCE\x00\x00\x00\x00\x80\x00\x08\x00\x01\x01\x00\x20\x06\x00\x00\xE4\x98\x52' > /dev/rfcomm0
Ref: How do I connect and send data to a bluetooth serial port on Linux? 
 
 
find $directory -type f -name '*' -exec mv {} $directory2/. \; 
ls / | xargs du -hs 

2010-10-12

Хлебопечкa


В наше время, наверное, вы можете разделить людей на тех, у кого уже есть хлебопечка и на тех, кто о ней еще не слышал.

Какую хлебопечь купить?
http://hlebopechka.ru/index.php?option=com_smf&Itemid=126&topic=3696.50
http://www.irecommend.ru/category/melkaya-kukhonnaya-tekhnika?tid=4692
http://bt.hotline.ua/gd/150/?o=1
http://price.ua/moulinex_ow2000/otzivi/72575.html
http://fotos.ua/orion/os-0k22/reviews/
http://www.e-katalog.com.ua/ORION-OS-0K51G.htm
http://fotos.ua/shop/138/
http://market.yandex.ru/search.xml?text=BM900AL&hid=198118&srnum=7

где купить
http://hlebopechka.kiev.ua
http://www.bestportal.com.ua/profiles/5ok/
http://www.5ok.com.ua/DetailProduct_141_102_50.html
http://bt.rozetka.com.ua/ru/products/procategory/244/index.html
tehnotrade.com.ua/
www.labaz.ua/
2000.com.ua/
artikul.com.ua
www.rozetka.com.ua
www.Fotos.ua
www.mobitrade.ua



Рецепт пицци
на стакан воды - 200грамов- два стакана муки - чайная ложка сухих дрожжей, чайная - сахара и соли с горкой ложку беру, столовая ложка растительного масла. Загружаем. Тесто должно быть как на густые оладьи. Оговорюсь , что мы делаем на большую жаровню. Выливаем тесто и равномерно распределяем рукой, предварительно намочите в воде или растительном масле, тогда тесто не будет прилипать. НА полу густой полуфабрикат сразу налаживаем начинку. Кто что любит. Мы в такой последовательности..мясо с луком мелко промолотым или колбасу, лук, варенные яйца, сырок плавленный, заливаем майонезом, сверху помидорчики тонко нарезанные кольцами. Немного дать постоять - минут 15 и в духовку для приготовления. Приятного аппетита.

Человек сам замешивает и печет хлеб по разным рецептам:
http://crucide.livejournal.com/

2010-08-11

Кулинария

Каши
55 каш:
http://www.gotovim.ru/recepts/groats/buckwheat/
http://supercook.ru/zz205-mess3.html
http://forum.say7.info/topic820.html

Соусы
http://www.vkysno.kiev.ua/d-recept-action-detail-rid-179-page-1.html

Kuking.net

2010-08-06

Видео, аудио, иллюстрации, фото

http://www.istockphoto.com/
http://www.gettyimages.com/
http://www.imagekind.com/

2010-08-02

Linux/MySQL/PHP/Chrome

Chrome

sudo apt-get remove google-chrome-stable
sudo dpkg -i google-chrome-stable_current_amd64.deb
relaunch chrome from chrome menu Help/About/Version->relaunch

MySQL
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;

You must reset your password using ALTER USER statement before executing this statement

SET PASSWORD=PASSWORD('asdfqwer'); 

# grep skip-grant-tables /lib/systemd/system/mysqld.service
#--skip-grant-tables


#################################

PHP 5.3.2
./configure --with-apxs2=/usr/sbin/apxs --with-mysqli=mysqlnd --with-mysql=/usr/local/mysql --with-gd --with-jpeg-dir --enable-soap

php-5.2.14]# ./configure --with-apxs2=/usr/sbin/apxs --enable-embedded-mysqli=shared --with-mysql=/usr/local/mysql3306 --with-gd --with-jpeg-dir --enable-soap


htaccess:

#two domains served from one root..
RewriteCond %{HTTP_HOST} domain-one.com
RewriteCond %{REQUEST_URI} !^/one
RewriteRule ^(.*)$ one/$1 [L]

RewriteCond %{HTTP_HOST} domain-two.com
RewriteCond %{REQUEST_URI} !^two
RewriteRule ^(.*)$ two/$1 [L]

***

RewriteCond %{HTTP_HOST} ^domain\.?com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain\.?com [NC]
RewriteCond %{REQUEST_URI} !/folder/
RewriteRule ^(.*)$ folder/$1 [L]

***

RewriteEngine On
RewriteBase /

# pointing for the domain abc.com to folder abc
ReWriteCond %{HTTP_HOST} abc.com
ReWriteCond %{REQUEST_URI} !abc/
ReWriteRule ^(.*)$ abc/$1 [L]

# pointing for the domain 123.com to folder 123
ReWriteCond %{HTTP_HOST} 123.com
ReWriteCond %{REQUEST_URI} !123/
ReWriteRule ^(.*)$ 123/$1 [L]

***

RewriteEngine On
RewriteBase /

# ---------------------------------------
# BEGIN Domain to folder mapping

# pointing domain_1.com to folder_1
ReWriteCond %{HTTP_HOST} domain_1.com
ReWriteCond %{REQUEST_URI} !folder_1/
ReWriteRule ^(.*)$ folder_1/$1 [L]

# pointing domain_2.com to folder_2
ReWriteCond %{HTTP_HOST} domain_2.com
ReWriteCond %{REQUEST_URI} !folder_2/
ReWriteRule ^(.*)$ folder_2/$1 [L]


Shell:
grep "RobinBobin" * | cut -d: -f1 | xargs -i -t cp ./{} ./RobinBobin/{}


.htaccess
php_value display_errors 1
php_value error_reporting E_ALL

ini_set('display_errors', 1);
error_reporting(E_ALL);