파일방2015. 7. 15. 12:56

NAS 프로그램인데

라즈베리용도 있다. ㄷㄷ

(그런데 라즈베리 USB 하드라서 속도가 안날텐데.. 게다가 USB로 랜이라...)


[링크 : http://www.openmediavault.org/]

[링크 : http://sourceforge.net/projects/openmediavault/files/]

    [링크 : http://blog.naver.com/mol70/220284425344]

'파일방' 카테고리의 다른 글

HelpNDoc  (0) 2015.07.29
goahead 웹 서버  (0) 2015.07.19
freetype / jam  (0) 2015.06.25
knime - 빅데이터 분석툴  (0) 2015.05.28
redmine / 레드마인  (0) 2015.04.14
Posted by 구차니
프로그램 사용/gcc2015. 7. 14. 16:59


$ cat size.c
#include <stdio.h>
#include <stdint.h>

void main()
{
        int a;
        int64_t b;

        printf("%d\n", sizeof(a));
        printf("%d\n", sizeof(b));

} 


$ ./a.out

4
8


+

#include <stdint.h>를 넣지 않으면 에러가 발생한다.

$ gcc size.c

size.c: In function ‘main’:

size.c:6:2: error: unknown type name ‘int64_t’


2013/01/13 - [프로그램 사용/gcc] - gcc 64bit 확장


Posted by 구차니
프로그램 사용/gcc2015. 7. 14. 16:47

나중에 리눅스 서버 하나 다시 만들어서 해봐야지


These -m switches are supported in addition to the above on AMD x86-64 processors in 64-bit environments.


-m32

-m64

Generate code for a 32-bit or 64-bit environment. The 32-bit environment sets int, long and pointer to 32 bits and generates code that runs on any i386 system. The 64-bit environment sets int to 32 bits and long and pointer to 64 bits and generates code for AMD's x86-64 architecture. 


[링크 : https://gcc.gnu.org/onlinedocs/gcc-3.1/gcc/i386-and-x86-64-Options.html]


64bit 우분투에서 빌드 하려니 에러가 발생한다. multilib을 설치하라는데..

$ gcc -m32 void.c

In file included from /usr/include/stdio.h:28:0,

                 from void.c:1:

/usr/include/features.h:324:26: fatal error: bits/predefs.h: No such file or directory

compilation terminated.


$ sudo apt-get install gcc-multilib

[링크 : http://uce.uniovi.es/tips/Programming/Cpp/forc32bitscompilation.html] 

[링크 : http://stackoverflow.com/questions/22355436/how-to-compile-32-bit-apps-on-64-bit-ubuntu]


'프로그램 사용 > gcc' 카테고리의 다른 글

gcc에서 precompiled header 사용하기  (0) 2015.07.29
gcc 64bit 변수 선언하기  (0) 2015.07.14
gcc 특정 표준 따르도록 강제하기  (0) 2015.07.14
크기가 0인 배열 허용  (0) 2015.06.29
ubuntu gcc가 바보  (2) 2013.09.19
Posted by 구차니
프로그램 사용/gcc2015. 7. 14. 16:34


-ansi

In C mode, this is equivalent to -std=c90. In C++ mode, it is equivalent to -std=c++98.


-std=

A value for this option must be provided; possible values are

‘c90’

‘c89’

‘iso9899:1990’

Support all ISO C90 programs (certain GNU extensions that conflict with ISO C90 are disabled). Same as -ansi for C code. 

‘iso9899:199409’

ISO C90 as modified in amendment 1. 

‘c99’

‘c9x’


[링크 : https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html]

'프로그램 사용 > gcc' 카테고리의 다른 글

gcc 64bit 변수 선언하기  (0) 2015.07.14
gcc 32bit/ 64bit 컴파일하기  (0) 2015.07.14
크기가 0인 배열 허용  (0) 2015.06.29
ubuntu gcc가 바보  (2) 2013.09.19
gcc 64bit 확장  (0) 2013.01.13
Posted by 구차니
Programming/C Win32 MFC2015. 7. 14. 16:07



$ gcc -v

Using built-in specs.

COLLECT_GCC=gcc

COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper

Target: x86_64-linux-gnu

Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu

Thread model: posix

gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) 


$ vi void.c

#include <stdio.h>


void main()

{

        void *fp;

        int a = 0;

        fp = &a;


        printf("sizeof(void) %d\n",sizeof(void));

        printf("fp %8X\n",fp);

        fp++;

        printf("fp %8X\n",fp);

} 

(남자니까) 경고따윈 무시한다!

$ gcc void.c

void.c: In function ‘main’:

void.c:9:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long unsigned int’ [-Wformat]

void.c:10:2: warning: format ‘%X’ expects argument of type ‘unsigned int’, but argument 2 has type ‘void *’ [-Wformat]

void.c:12:2: warning: format ‘%X’ expects argument of type ‘unsigned int’, but argument 2 has type ‘void *’ [-Wformat]


어? 연산이 되네? ㄷㄷㄷ 일단은 byte로 간주..

어? 게다가.. 왜 void의 sizeof가 1?

$ ./a.out
sizeof(void) 1
fp E9F5689C
fp E9F5689D


+

6.23 Arithmetic on void- and Function-Pointers


In GNU C, addition and subtraction operations are supported on pointers to void and on pointers to functions. This is done by treating the size of a void or of a function as 1.


A consequence of this is that sizeof is also allowed on void and on function types, and returns 1.


The option -Wpointer-arith requests a warning if these extensions are used.


[링크 : https://gcc.gnu.org/onlinedocs/gcc/Pointer-Arith.html]


+

Compiler Error CS0242

The operation in question is undefined on void pointers

Incrementing a void pointer is not allowed. For more information, see Unsafe Code and Pointers (C# Programming Guide).

[링크 : https://msdn.microsoft.com/en-us/library/dhyat531(v=vs.90).aspx] 


'Programming > C Win32 MFC' 카테고리의 다른 글

rand()와 RAND_MAX  (0) 2015.10.05
Cppcheck  (0) 2015.09.30
가변인자를 다시 넘겨주기  (2) 2015.07.07
printf 가변인자의 비밀?  (0) 2015.06.18
gcc 컴파일러 -D 옵션  (0) 2015.05.19
Posted by 구차니
프로그램 사용/Putty2015. 7. 14. 14:21

putty를 통해서 CR+LF로 전송이 가능한가 했더니..

보이는 부분에 대해서만 가능한 듯...

기본적으로 putty는 \n 만 보내는 것으로 보인다.



LF는 line feed - \n 으로 대개 표기되며

CR은 carriage return - \r 로 대개 표기된다.


4.3.3 ‘Implicit CR in every LF’

Most servers send two control charactersCR and LF, to start a new line of the screen. The CR character makes the cursor return to the left-hand side of the screen. The LF character makes the cursor move one line down (and might make the screen scroll).

Some servers only send LF, and expect the terminal to move the cursor over to the left automatically. If you come across a server that does this, you will see a stepped effect on the screen, like this:

First line of text
                  Second line
                             Third line

If this happens to you, try enabling the ‘Implicit CR in every LF’ option, and things might go back to normal:

First line of text
Second line
Third line

4.3.4 ‘Implicit LF in every CR’

Most servers send two control characters, CR and LF, to start a new line of the screen. The CR character makes the cursor return to the left-hand side of the screen. The LF character makes the cursor move one line down (and might make the screen scroll).

Some servers only send CR, and so the newly written line is overwritten by the following line. This option causes a line feed so that all lines are displayed.


[링크 : http://tartarus.org/~simon/putty-snapshots/htmldoc/Chapter4.html]


'프로그램 사용 > Putty' 카테고리의 다른 글

ssh X11 forwarding 속도 향상.. 2?  (0) 2016.02.03
putty chrome socks5 / dns remote  (0) 2014.12.18
putty로 proxy 설정하기 (socks5 + firefox)  (0) 2014.12.17
linux용 putty  (2) 2011.09.21
putty를 이용한 vnc 터널링  (1) 2011.06.21
Posted by 구차니
embeded/raspberry pi2015. 7. 13. 23:44

음.. 막상해보려니 125KHz 카드가 없다...

신용카드의 교통카드는.. 125KHz가 아니라 무리려나?

나중에 다른 카드 생기면 해봐야 할 듯.. ㅠㅠ


Voltage: 4.75-5.25V

Working Frequency: 125 KHz

Sensing Distance(Max): 70mm

TTL Output: 9600 baudrate, 8 data bits, 1 stop bit, and no verify bit

Wiegand Output: 26 bits Wiegand format, 1 even verify bit, 24 data bits, and 1 odd verify bit

[링크 : http://www.seeedstudio.com/wiki/Grove_-_125KHz_RFID_Reader] 


125Khz  EM카드

저렴하고 광범위하게 사용되고 있는카드


13.56Mhz MF카드

카드의 데이터값을 수정할 수 있으며

교통카드가 대표적인 MF카드임.

[링크 : http://korearfidtag.com/] 


+

2015.07.14

9600bps로 UART 모드 설정시 그냥 읽히는데..

putty 특성상 출력 안되는건 패스하니까 log로 분석


위는 카드에 써있는 숫자

아래는 읽힌 데이터

일치하진 않네...


인식해서 날아오는데 까지 약 1초 정도 소요되는 듯.



카드에 기재된 거랑 동일하게 읽히진 않네...



Posted by 구차니
embeded/raspberry pi2015. 7. 13. 23:27

릴레이는 단순하게 HI/LO 입력에 따라 on/off 스위치라 별거 없으니 대충~

당연히(!) 귀차니즘으로 wiring pi 기준 1번 / GPIO18번에 연결


$ gpio mode 1 output

$ gpio write 1 1


$ gpio write 1 0



[링크 : http://www.seeedstudio.com/depot/Grove-Relay-p-769.html]

Posted by 구차니
embeded/raspberry pi2015. 7. 13. 23:14

3.3-5V 이나 5V추천

탐지거리 3cm-4m

[링크 : http://www.seeedstudio.com/depot/Grove-Ultrasonic-Ranger-p-960.html]


다른 소스들의 예제와 다르게 이녀석...

Trigger / Echo가 아닌 Signal 하나 뿐이다


그래서 Trigger로 output 모드 설정후 전송하고 재빠르게

Echo로 input 모드로 설정후 받아 시간을 재도록 수정해야 한다.


포트는 만만한(?) GPIO18번 PWM 포트(wiring pi 기준 1번)으로 설정

흰색 - 5V

검정 - GND

보라 - GPIO18 ->A0




$ cat ultrasonic_1.py

#!/usr/bin/python

#+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

#|R|a|s|p|b|e|r|r|y|P|i|-|S|p|y|.|c|o|.|u|k|

#+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

#

# ultrasonic_1.py

# Measure distance using an ultrasonic module

#

# Author : Matt Hawkins

# Date   : 09/01/2013

# -----------------------


# Import required Python libraries

import time

import RPi.GPIO as GPIO


# Use BCM GPIO references

# instead of physical pin numbers

GPIO.setmode(GPIO.BCM)


# Define GPIO to use on Pi

GPIO_TRIGGER = 18

GPIO_ECHO    = 18


print "Ultrasonic Measurement"


# Set pins as output and input

GPIO.setup(GPIO_TRIGGER,GPIO.OUT)  # Trigger


# Set trigger to False (Low)

GPIO.output(GPIO_TRIGGER, False)


# Allow module to settle

time.sleep(0.5)


# Send 10us pulse to trigger

GPIO.output(GPIO_TRIGGER, True)

time.sleep(0.00001)

GPIO.output(GPIO_TRIGGER, False)

start = time.time()


GPIO.setup(GPIO_ECHO,GPIO.IN)      # Echo

while GPIO.input(GPIO_ECHO)==0:

  start = time.time()


while GPIO.input(GPIO_ECHO)==1:

  stop = time.time()


# Calculate pulse length

elapsed = stop-start


# Distance pulse travelled in that time is time

# multiplied by the speed of sound (cm/s)

distance = elapsed * 34300


# That was the distance there and back so halve the value

distance = distance / 2


print "Distance : %.1f" % distance


# Reset GPIO settings

GPIO.cleanup() 


자가 없어서 대충 한뼘(21cm)로 해봤는데 얼추 맞는 기분

pi@raspberrypi ~/src/sonic $ sudo python ultrasonic_1.py

Ultrasonic Measurement

Distance : 154.8

pi@raspberrypi ~/src/sonic $ sudo python ultrasonic_1.py

Ultrasonic Measurement

Distance : 3.0

pi@raspberrypi ~/src/sonic $ sudo python ultrasonic_1.py

Ultrasonic Measurement

Distance : 9.1

pi@raspberrypi ~/src/sonic $ sudo python ultrasonic_1.py

Ultrasonic Measurement

Distance : 26.3 


대충 소스 받아서 수정

[링크 : http://www.raspberrypi-spy.co.uk/2012/12/ultrasonic-distance-measurement-using-python-part-1/]

Posted by 구차니

음? 전혀.. 처음든는 게임이다?





Posted by 구차니