Linux API/linux2016. 4. 4. 09:21

어떻게 보면 당연한..(?)

함수 포인터


#include <stdio.h>

#include <dlfcn.h>

#include "ctest.h"


int main(int argc, char **argv) 

{

   void *lib_handle;

   double (*fn)(int *);

   int x;

   char *error;


   lib_handle = dlopen("/opt/lib/libctest.so", RTLD_LAZY);

   if (!lib_handle) 

   {

      fprintf(stderr, "%s\n", dlerror());

      exit(1);

   }


   fn = dlsym(lib_handle, "ctest1");

   if ((error = dlerror()) != NULL)  

   {

      fprintf(stderr, "%s\n", error);

      exit(1);

   }


   (*fn)(&x);

   printf("Valx=%d\n",x);


   dlclose(lib_handle);

   return 0;

[링크 : http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html]


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

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

'Linux API > linux' 카테고리의 다른 글

메시지 큐 - ipc  (0) 2016.06.28
pthread mutex shm_open  (0) 2016.06.27
리눅스 커널 모듈 관련 문서  (0) 2015.11.06
readl(), writel()  (0) 2015.11.06
리눅스 모듈 프로그래밍 관련  (0) 2015.10.30
Posted by 구차니
Programming/C Win32 MFC2016. 4. 4. 09:20

엥.. 왜 이런거 관련 내용이 검색이 안되지 -ㅁ-?


    hInst = LoadLibrary("SmallDll.dll");

    if(hInst == NULL)

        return 1;


    // 호출한 함수를 맵핑

    fAPlusB = (APlusB)GetProcAddress(hInst, "APlusB");

    fAMinusB = (AMinusB)GetProcAddress(hInst, "AMinusB"); 

[링크 : http://wwwi.tistory.com/72]



HMODULE WINAPI LoadLibrary(

  _In_ LPCTSTR lpFileName

);

[링크 : https://msdn.microsoft.com/en-us/library/windows/desktop/ms684175(v=vs.85).aspx]



FARPROC WINAPI GetProcAddress(

  _In_ HMODULE hModule,

  _In_ LPCSTR  lpProcName

);

[링크 : https://msdn.microsoft.com/ko-kr/library/windows/desktop/ms683212(v=vs.85).aspx]



lib로 하는거네...

// MathFuncsDll.h

#ifdef MATHFUNCSDLL_EXPORTS

#define MATHFUNCSDLL_API __declspec(dllexport) 

#else

#define MATHFUNCSDLL_API __declspec(dllimport) 

#endif


// MyExecRefsDll.cpp

// compile with: /EHsc /link MathFuncsDll.lib 


[링크 : https://msdn.microsoft.com/ko-kr/library/ms235636.aspx]

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

MFC / stdlib / qsort example  (0) 2016.12.19
MFC UpdateData()  (0) 2016.12.16
가변 매크로 __VA_ARGS__  (0) 2016.03.18
#import ?  (0) 2015.12.21
"\n" 의 cpu 점유율?  (0) 2015.10.12
Posted by 구차니

왜이렇게 빨리해 ㄷㄷ




[링크 : http://www.hiseoulbike.com/]

Posted by 구차니
embeded/arduino(genuino)2016. 4. 1. 16:40

음.. 우리나라가 미친듯 비싸게 파는걸려나..


The MPU-6050 is not expensive, especially given the fact that it combines both an accelerometer and a gyro.

[링크 : http://playground.arduino.cc/Main/MPU-6050]



어라.. 3.3V 짜리인 i2c 장비를 레벨 쉬프트 하지 않고 쓸수가 있나보네?


[링크 : http://playground.arduino.cc/Main/I2CBi-directionalLevelShifter]

Posted by 구차니
embeded/arduino(genuino)2016. 3. 31. 20:25

temperature = (ADCW - 324.31) / 1.22


[링크 : http://playground.arduino.cc/Main/InternalTemperatureSensor]





[링크 : http://www.atmel.com/images/...328p_datasheet_complete.pdf]

Posted by 구차니
embeded/arduino(genuino)2016. 3. 31. 19:03

엥? winavr에서도 안되었던가??

급 멘붕 ㄷㄷ


char *dtostrf(double val, signed char width, unsigned char prec, char *s)


Use this method to convert it to a C-Style string and then use sprintf, eg:


char str_temp[6];


/* 4 is mininum width, 2 is precision; float value is copied onto str_temp*/

dtostrf(temp, 4, 2, str_temp);

sprintf(temperature,"%s F", str_temp);

[링크 : http://stackoverflow.com/questions/27651012/arduino-sprintf-float-not-formatting]

[링크 : http://forum.arduino.cc/index.php?topic=175478.0]


[링크 : http://whiteat.com/bPDS_AVR/28406]

Posted by 구차니

초코렛이나 구매하려고 로이스 홈페이지 갔다가

약도 위에 빨갛게 떠서 먼가해서 봤더니... 헐?!?

회사 홈페이지도 같은 지도 쓰니 언넝 수정을 해야지...


[링크 : http://blog.daum.net/daummaps/482]

'개소리 왈왈 > 직딩의 비애' 카테고리의 다른 글

크아아앙 지름신님 ㅠㅠ 살려주세요 젭라 ㅠㅠ  (0) 2016.04.28
포지션 : 잡캐?  (0) 2016.04.25
po지름wer!!!  (0) 2016.03.24
망할 locky... cryptowall 계열...  (0) 2016.03.17
망할 locky 랜섬웨어 -_-  (3) 2016.03.16
Posted by 구차니
Microsoft/Windows2016. 3. 31. 15:57

먼가 깨알 같은 top은 안되요의 압박

bash를 실행하면

우분투쪽 시스템을 끌어오는게 아닌데도 불구하고..

UNIX subsystem을 통해 바로 bash를 통해 elf(unix) 쪽 파일을 바로 실행도 가능하고..

먼가.. 맥을 잡아버릴려는 느낌인거 같기도 하고

머하는 짓인가 싶기도 하고.. ㄷㄷ


[링크 : https://sec.ch9.ms/sessions/build/2016/P488.mp4]

[링크 : http://techcrunch.com/.../be-very-afraid-hell-has-frozen-over-bash-is-coming-to-windows-10/]

[링크 : http://www.clien.net/cs2/bbs/board.php?bo_table=news&wr_id=2146552]

'Microsoft > Windows' 카테고리의 다른 글

메모장 F5 단축키..  (0) 2016.08.10
win7 자격 증명 저장관련  (0) 2016.06.23
그래픽 카드 성능 향상...?? system.ini irq  (0) 2016.02.16
win7 starter / home premium 메모리 사용량  (0) 2015.11.08
win7 starter?  (0) 2015.11.07
Posted by 구차니
embeded/arduino(genuino)2016. 3. 31. 10:30

필터는 나중에 적용하고..

걍.. atan()만 쓰면 끝나나?



double x_angle = -atan((double)ay/(double)az)*180.0 / 3.1416;

[링크 : http://hs36.tistory.com/19]


[링크 : http://pinkwink.kr/73]

[링크 : http://mechaworld.tistory.com/11]



+


2016/04/06 - [이론 관련] - 가속도계로 각도계산하기


Posted by 구차니
embeded/arduino(genuino)2016. 3. 31. 09:51

음.. 이제 좀 마음에 들게 되긴했는데..

각도를 어떻게 받고. 어떤 각도를 계산해야 하려나..


#include <avr/io.h>
#include <Wire.h>

#define I2C_ID  0x53 // ADXL-345

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Wire.begin();

  // adxl345 initialize
  // power setting
  Wire.beginTransmission(I2C_ID);
    Wire.write(byte(0x2d));
    Wire.write(byte(0x18));
  Wire.endTransmission();

  // range setting
  Wire.beginTransmission(I2C_ID);
    Wire.write(byte(0x31));
    Wire.write(byte(0x09));
  Wire.endTransmission();
}

void loop() {
  // put your main code here, to run repeatedly:
  char str[30];
  char data[6];
  unsigned char idx = 0;
  short acc_x;
  short acc_y;
  short acc_z;

  // data request
  Wire.beginTransmission(I2C_ID);
    Wire.write(byte(0x32));
  Wire.endTransmission();
  Wire.requestFrom(0x53, 6);

  idx = 0;
  while (Wire.available())
    data[idx++] = Wire.read();

  acc_x = (data[1] << 8) | data[0];
  acc_y = (data[3] << 8) | data[2];
  acc_z = (data[5] << 8) | data[4];

  sprintf(str,"x:%6d y:%6d z:%6d",acc_x, acc_y, acc_z);
  Serial.println(str);

  delay(100);
}



FULL_RES 끄고(10bit output / 0~1023) +-16g로 출력

#include <avr/io.h>
#include <math.h>
#include <Wire.h>

#define I2C_ID  0x53 // ADXL-345

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Wire.begin();

  // adxl345 initialize
  // power setting
  Wire.beginTransmission(I2C_ID);
    Wire.write(byte(0x2d));
    Wire.write(byte(0x18));
  Wire.endTransmission();

  // range setting
  Wire.beginTransmission(I2C_ID);
    Wire.write(byte(0x31));
    Wire.write(byte(0x03));
  Wire.endTransmission();
}

void loop() {
  // put your main code here, to run repeatedly:
  char str[30];
  char data[6];
  unsigned char idx = 0;
  short acc_x;
  short acc_y;
  short acc_z;
  double deg_x;
  double deg_y;

  // data request
  Wire.beginTransmission(I2C_ID);
    Wire.write(byte(0x32));
  Wire.endTransmission();
  Wire.requestFrom(0x53, 6);

  idx = 0;
  while (Wire.available())
    data[idx++] = Wire.read();

  acc_x = (data[1] << 8) | data[0];
  acc_y = (data[3] << 8) | data[2];
  acc_z = (data[5] << 8) | data[4];

  if(acc_z == 0)
  {
    deg_x = 0.0;
    deg_y = 0.0;
  }
  else
  {
    deg_x = atan((double)acc_x / (double)acc_z) * 57.2957;
    deg_y = atan((double)acc_y / (double)acc_z) * 57.2957;
  }
  
  sprintf(str,"x:%6d y:%6d z:%6d",acc_x, acc_y, acc_z);
  Serial.println(str);
  
  sprintf(str,"x:%d y:%d",(short)deg_x, (short)deg_y);
  Serial.println(str);

  delay(100);
}



#include <avr/io.h>
#include <math.h>
#include <Wire.h>

#define I2C_ID  0x53 // ADXL-345

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Wire.begin();

  // adxl345 initialize
  // power setting
  Wire.beginTransmission(I2C_ID);
    Wire.write(byte(0x2d));
    Wire.write(byte(0x18));
  Wire.endTransmission();

  // range setting
  Wire.beginTransmission(I2C_ID);
    Wire.write(byte(0x31));
    Wire.write(byte(0x02));
  Wire.endTransmission();
}

void loop() {
  // put your main code here, to run repeatedly:
  char str[30];
  char str_x[15];
  char str_y[15];
  char data[6];
  unsigned char idx = 0;
  short acc_x;
  short acc_y;
  short acc_z;
  double deg_x;
  double deg_y;

  // data request
  Wire.beginTransmission(I2C_ID);
    Wire.write(byte(0x32));
  Wire.endTransmission();
  Wire.requestFrom(0x53, 6);

  idx = 0;
  while (Wire.available())
    data[idx++] = Wire.read();

  acc_x = (data[1] << 8) | data[0];
  acc_y = (data[3] << 8) | data[2];
  acc_z = (data[5] << 8) | data[4];

  if(acc_z == 0)
  {
    deg_x = 0.0;
    deg_y = 0.0;
  }
  else
  {
    deg_x = atan((double)acc_x / (double)acc_z) * 57.2957;
    deg_y = atan((double)acc_y / (double)acc_z) * 57.2957;
  }
  
  sprintf(str,"x:%6d y:%6d z:%6d",acc_x, acc_y, acc_z);
  Serial.println(str);

  dtostrf(deg_x, 4,2, str_x);
  dtostrf(deg_y, 4,2, str_y);
  sprintf(str,"x:%s y:%s",str_x, str_y);
  Serial.println(str);

  delay(100);
}


Posted by 구차니