본문 바로가기

리눅스 기반 서버프로그램 #include #include #include #include #include #include int main() { int servSock; int clntSock; int iRet; struct sockaddr_in echoServAddr; struct sockaddr_in echoClntAddr; unsigned short echoServPort; // server app port address unsigned int clntLen; unsigned char ucBuffer[500]; echoServPort = 9999; // 서버의 포트주소는 대부분 고정시킴 // 1. 소켓 생성 servSock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (servSoc.. 더보기
ATmega2560으로 LED 깜빡이기 ATmega 시리즈는 ATMEL사에서 직접 설계한 AVR 프로세서를 사용하는 MCU로8비트 구조로 설계되어있다. ARM과 같이 롬라이터 없이 프로그램을 삽입할 수 있는 In-System Programmable Flash를 장착하고 있으며,ARM의 SAM-BA보다 훨씬 사용하기 편리하다. GNU에서 만든 GCC컴파일러인 WinAVR을 설치하고 그 Makefile만 가져다 코딩하면 될 정도로 사용이 무척 간편하다. 우선 WinAVR의 Makefile을 살펴보자. 43 # MCU name44 MCU = atmega2560 47 # Processor frequency.48 # This will define a symbol, F_CPU, in all source code files equal to the 49 #.. 더보기
구조체를 이용한 메모리 접근 지금껏 ARM에 코딩할 때 define문으로 레지스터를 각각 지정하여 사용하는 방법을 썼는데, ATMEL사에서 제공하는 헤더파일을 이용하면각기 따로 define문을 이용하여 지정할 필요 없이바로 코드를 작성할 수 있다. 이는 메모리 주소와 구조체, 포인터의 특성을 이용하여 사용하는 것이다. #include #define BASE ((struct SMART *)0x12FF60) struct SMART { int A; int B; int C; int D; }; int main() { int array[4] = {0x11, 0x22, 0x33, 0x44}; int *ip = array; struct SMART *ssp; printf(" int[] : %X\t%X\t%X\t%X\n", array[0], arra.. 더보기