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 구차니

음.. 막상해보려니 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초 정도 소요되는 듯.



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



'하드웨어 > rfid_nfc_smartcard' 카테고리의 다른 글

rfid, smart card reader  (0) 2025.02.12
ubunut smart card 읽기  (0) 2025.02.12
ATR (Answer To Reset)  (0) 2025.02.12
rfid 12.5M / 125k  (0) 2024.07.25
의약품 RFID  (2) 2023.09.12
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 구차니
개소리 왈왈/블로그2015. 7. 12. 21:29

글을 안써서 그런가? 플랫~ ㅋㅋㅋㅋ




'개소리 왈왈 > 블로그' 카테고리의 다른 글

네이버가.. 50% 돌파?  (2) 2015.07.31
출장 3일의 여파?  (2) 2015.07.16
댓글 알림은 있는데 댓글이 사라졌다?  (4) 2015.06.11
한RSS 역사의 뒤안길로..  (0) 2015.05.14
벌써... 일년?  (0) 2015.05.13
Posted by 구차니
Programming/C Win32 MFC2015. 7. 7. 13:45

현실적으로 불가능 -_-

다만 vsprintf 는 인자를 받으므로 인자를 이용해서 다시 문자열을 생성하는 식으로 쓸 수는 있음


[링크 : http://stackoverflow.com/questions/2060578/is-it-possible-to-write-a-varargs-function-that-sends-it-argument-list-to-anothe]


#include <stdio.h>

int printf(const char *format, ...);

int fprintf(FILE *stream, const char *format, ...);

int sprintf(char *str, const char *format, ...);

int snprintf(char *str, size_t size, const char *format, ...);


#include <stdarg.h>

int vprintf(const char *format, va_list ap);

int vfprintf(FILE *stream, const char *format, va_list ap);

int vsprintf(char *str, const char *format, va_list ap);

int vsnprintf(char *str, size_t size, const char *format, va_list ap);


[링크 : http://linux.die.net/man/3/vsprintf] 


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

Cppcheck  (0) 2015.09.30
void형 포인터 ++  (0) 2015.07.14
printf 가변인자의 비밀?  (0) 2015.06.18
gcc 컴파일러 -D 옵션  (0) 2015.05.19
setjmp, longjmp  (0) 2015.05.19
Posted by 구차니
embeded/raspberry pi2015. 7. 7. 06:54

그냥 쏘고 받고

그 시간 간격재고 끝인가? 굳이.. 몇개의 파형을 안보내는 되는 걸려나..


[링크 : http://www.modmypi.com/blog/hc-sr04-ultrasonic-range-sensor-on-the-raspberry-pi]

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

Posted by 구차니
embeded/raspberry pi2015. 7. 6. 23:40

귀찮아서 여전히 USB to RS232로 하면서 뻔뻔한 제목 ㅋㅋ

땜질 안되어 있는 녀석이라 핀 몇개만 일단 박고 대충 결선하고 테스트!


핀이 하나도 없네?!?!


으쌰으쌰 대충 땜질하자


귀찮으니.. 3.3V를 내줄수 있는 USB to 232를 애용합시다? ㅋㅋ

일단 당연하지만 RX와 TX는 서로 엇갈리게 연결해준다.


232의 RXBT의 TX

232의 TXBT의 RX


전원도 대충~ GND와 3.3V 연결


3.3V 입력

TTL 레벨에 38400 으로 연결하고

명령어를 치면되는데.. \r\n 이라 그냥 입력이 불가능해서

Putty로는 테스트 불가 -_ㅠ


1. Set work mode

\r\n+STWMOD=1\r\n Set work mode Master




[링크 : http://www.seeedstudio.com/wiki/Serial_port_bluetooth_module_(Master/Slave)]

[링크 : http://www.seeedstudio.com/wiki/images/e/e8/BTSoftware_Instruction.pdf]

    [링크 : http://www.seeedstudio.com/wiki/Bluetooth_Shield]


Posted by 구차니