2012의 게시물 표시

android ip check

1. prepare project/jni project/AndoroidMainfest.xml Native C or C++ Code manifest sample <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="com.mycompany.mynativeapp"     android:versionCode="1"     android:versionName="1.0" >     <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="8" />          <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>   <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>     <!-- This .apk has no Java code itself, so set hasCode to false. -->     <application android:label="@string/app_name" android:hasCode="false">         <!-- Our activity is the built-in NativeActi

linux / unix 에서 자기 IP 얻어오기 ( android 포함 )

linux / unix 에서 자기 IP 얻어오기 ( android 포함 ) ( C, C++ ) ( get my ip in android native NDK ) 내용 : 로컬의 IP를 찾아 표시한다.  - 외부 IP를 얻는 방법은 따로... 펌 : http://yegam400.tistory.com/71 보통 자기 ip 알아보는데는 gethostbyname을 많이 사용하지만, 이것은 디바이스의 ethernet(eth0, eth1,...)를 바로 가지고 오므로 정확합니다. Loop back도 가지고 오네요. 리눅스/유닉스 소스코드입니다. #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/socket.h> #include <unistd.h> #include <netinet/in.h> #include <arpa/inet.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <net/if.h> #include <arpa/inet.h> int main() {     // 이더넷 데이터 구조체     struct ifreq *ifr;     struct sockaddr_in *sin;     struct sockaddr *sa;     // 이더넷 설정 구조체     struct ifconf ifcfg;     int fd;     int n;     int numreqs = 30;     fd = socket(AF_INET, SOCK_DGRAM, 0);     // 이더넷 설정정보를 가지고오기 위해서     // 설정 구조체를 초기화하고     // ifreq데이터는 ifc_buf에 저장되며

AVR 강좌 - ATmega 퓨즈비트(fuse bit)란 무엇인가

이미지
AVR 강좌 - ATmega 퓨즈비트(fuse bit)란 무엇인가 : •  퓨즈비트란 ? 퓨즈비트 (fuse bit) 란  AVR ATmega  컨트롤러의 기능 설정용 제어 비트라고 할 수 있다 .  퓨즈 비트는  AVR 의 모델에 따라 그 메모리의 길이나 비트 구성이 다르다 .  내용은 거의 비슷하여 대체로 다음과 같은 기능들을 갖는다 . - JTAGEN, OCDEN: JTAG 의 사용 가능 여부를 선택 - SPIEN:  다운로드 케이블에 의한 직렬 프로그래밍 사용 가능 여부를 선택 - CKSEL4~CKSEL0, CKOPT:  시스템 클럭의 소스나 오실레이터 옵션을 선택 - SUT1~SUT0:  기동 시간을 선택 - WDTON:  위치독 타이머 사용 가능 여부를 선택 - BODEN, BODLEVEL: BOD  기능의 사용 여부 및  BOD  전압 레벨을 선택 - BOOTSZ1~BOOTSZE, BOOTRST:  부트 메모리 사이즈나 리셋 벡터를 선택 - EESAVE:  칩삭제 명령에서 내부  EEPROM 을 삭제할 것인지 여부를 선택 - M103C:  그 이전 모델과의 호환 모드로 동작할지 여부를 선택 •   ATmega128A Datasheet  참고 .         →   ATmega 128A 의 퓨트 비트 설정은 다음과 같이 하였다 .  

06 이클립스(Eclipse) CDT 설치 - kkamagui의 프로그래밍 작업실

06 이클립스(Eclipse) CDT 설치 - kkamagui의 프로그래밍 작업실 : 'via Blog this'

How to run Ubuntu Linux on the MK802 $74 PC-on-a-stick - Liliputing

이미지
How to run Ubuntu Linux on the MK802 $74 PC-on-a-stick - Liliputing : The  MK802  is a tiny PC that looks like a USB thumb drive. While it ships with Google Android 4.0, it’s actually pretty easy to convince it to run an alternate operating system. In fact, if you have a properly prepared microSD card, all you need to do is insert the memory card, turn on the MK802, and it will boot Ubuntu 10.04 Linux. Ubuntu boots very quickly on the little computer, although performance is a little on the slow side. That’s not surprising, given the MK802′s relatively anemic hardware. It has a 1.5 GHz Allwinner A10 ARM Cortex-A8 processor and 4GB of storage — pretty much what you’d expect from a 2010-era smartphone. While the MK802 won’t win any speed awards, it’s pretty impressive that this $74 computer  can run a full desktop-style operating system at all. While it takes a kind of long time to launch some apps such as OpenOffice.org and Firefox, they all work pretty well once they’re up and runni

c++ - Sleep Less Than One Millisecond - Stack Overflow

c++ - Sleep Less Than One Millisecond - Stack Overflow : Actually using this usleep function will cause a big memory/resource leak. (depending how often called) use this corrected version int usleep ( long usec ) {     struct timeval tv ;     fd_set dummy ;     SOCKET s = socket ( PF_INET , SOCK_STREAM , IPPROTO_TCP );     FD_ZERO (& dummy );     FD_SET ( s , & dummy );     tv . tv_sec = usec / 1000000L ;     tv . tv_usec = usec % 1000000L ;     bool sucess = 0 == select ( 0 , 0 , 0 , & dummy , & tv );     closesocket ( dummy );     return sucess ; } On windows however, the use of select forces you to include the winsock library which has to be initialized like this in your application: WORD wVersionRequested = MAKEWORD ( 1 , 0 ); WSADATA wsaData ; WSAStartup ( wVersionRequested , & wsaData ); And then the select won't allow you to be called without any socket so you have to do a little more to create a microslee

c++ - Sleep Less Than One Millisecond - Stack Overflow

c++ - Sleep Less Than One Millisecond - Stack Overflow : On windows you have a problem you typically never encounter on Unix. That is how to get a thread to sleep for less than one millisecond. On Unix you typically have a number of choices (sleep, usleep and nanosleep) to fit your needs. On windows however there is only  Sleep  with millisecond granularity. You can however use the select system call to create a microsecond sleep. On Unix this is pretty straight forward: int usleep ( long usec ) {     struct timeval tv ;     tv . tv_sec = usec / 1000000L ;     tv . tv_usec = usec % 1000000L ;     return select ( 0 , 0 , 0 , 0 , & tv ); } On windows however, the use of select forces you to include the winsock library which has to be initialized like this in your application: WORD wVersionRequested = MAKEWORD ( 1 , 0 ); WSADATA wsaData ; WSAStartup ( wVersionRequested , & wsaData ); And then the select won't allow you to be called without any socket s