'잡동사니'에 해당되는 글 13669건

  1. 2022.05.04 libmodbus tcp 예제
  2. 2022.05.03 libmodbus
  3. 2022.05.03 modbus tcp 테스트 툴
  4. 2022.05.02 kinect skeleton tracking
  5. 2022.05.02 kinect 윈도우 vs 리눅스
  6. 2022.05.02 debian noroot 와 userland
  7. 2022.05.01 mac 창 분할 사용하기
  8. 2022.05.01 맥 멀티 모니터 설정
  9. 2022.04.30 메인보드 구매, 교체
  10. 2022.04.29 장모님댁

유닛 테스트 하는 프로그램을 뜯어 보면 서비스 초기화 하는 코드를 분석하기 유리할 듯

 

[링크 : https://github.com/stephane/libmodbus/blob/master/tests/unit-test-server.c]

[링크 : https://github.com/stephane/libmodbus/blob/master/tests/unit-test-client.c]

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

modbus tcp  (0) 2022.05.04
libmodbus 예제 프로그램  (0) 2022.05.04
libmodbus  (0) 2022.05.03
modbus tcp 테스트 툴  (0) 2022.05.03
modbus tcp library  (0) 2022.04.25
Posted by 구차니

 

$ apt-cache search libmodbus
libmodbus5 - library for the Modbus protocol
libmodbus-dev - development files for the Modbus protocol library

 

libmodbus에서 기본으로 제공하는 예제인데

127.0.0.1의 1502번 포트로 접속을 해서 0번 address에 5바이트를 읽어 오도록 하는 명령이다

modbus로는 0x03(read holding register) 명령으로 5바이트 읽는 건데..

이게 modbus tcp의 master 라고 해야하나?

#include <stdio.h>
#include <modbus.h>

int main(void) {
  modbus_t *mb;
  uint16_t tab_reg[32];

  mb = modbus_new_tcp("127.0.0.1", 1502);
  modbus_connect(mb);

  /* Read 5 registers from the address 0 */
  modbus_read_registers(mb, 0, 5, tab_reg);

  modbus_close(mb);
  modbus_free(mb);
}

[링크 : https://libmodbus.org/documentation/]

[링크 : https://libmodbus.org/]

 

Client

The Modbus protocol defines different data types and functions to read and write them from/to remote devices. The following functions are used by the clients to send Modbus requests:

Server

The server is waiting for request from clients and must answer when it is concerned by the request. The libmodbus offers the following functions to handle requests:

[링크 : https://libmodbus.org/docs/v3.0.8/]

 

SYNOPSIS

int modbus_receive(modbus_t *ctx, uint8_t *req);

DESCRIPTION

The modbus_receive() function shall receive an indication request from the socket of the context ctx. This function is used by Modbus slave/server to receive and analyze indication request sent by the masters/clients.
If you need to use another socket or file descriptor than the one defined in the context ctx, see the function modbus_set_socket(3).
 

[링크 : https://libmodbus.org/docs/v3.0.8/modbus_receive.html]

 

SYNOPSIS

*int modbus_reply(modbus_t *ctx, const uint8_t *req, int req_length, modbus_mapping_t *mb_mapping);

DESCRIPTION

The modbus_reply() function shall send a response to received request. The request req given in argument is analyzed, a response is then built and sent by using the information of the modbus context ctx.
If the request indicates to read or write a value the operation will done in the modbus mapping mb_mapping according to the type of the manipulated data.
If an error occurs, an exception response will be sent.
This function is designed for Modbus server.
 

[링크 : https://libmodbus.org/docs/v3.0.8/modbus_reply.html]

 

MODBUS-TCP 통신규격에는 마스터(Client)와 슬레이브(Server)의 역할이 나누어져 있습니다. 슬레이브(Server)는 마스터(Client)가 요청하는 데이터에 대해 응답을 해줍니다. 주로 마스터(Client)에는 산업용터치 HMI 기기, 또는 PC 와 같은 상위 기기가 위치합니다. 그리고 슬레이브(Server)에는 TCPPORT 나 PLC 등이 위치합니다.
슬레이브(Server)는 상위기기에서 요청하는 동작만을 하는 수동적인 위치에 있습니다. 반면 마스터(Client)쪽에서는 원하는 데이터를 읽어오거나, 원하는 데이터를 기입하는 등 적극적으로 슬레이브(Server) 기기를 다루어 주어야 합니다.

[링크 : http://comfilewiki.co.kr/ko/doku.php?id=tcpport:modbus-tcp_프로토콜이란:index]

[링크 : https://gosuway.tistory.com/374]

 

+

int main(void)
{
  int i;
  int s = -1;
  modbus_t *ctx;
  modbus_mapping_t *mb_mapping;
  
  ctx = modbus_new_tcp("127.0.0.1", 1502);
  //    modbus_set_debug(ctx, TRUE); 
  
  mb_mapping = modbus_mapping_new(0, 0, 500, 500);
  if (mb_mapping == NULL) {
    fprintf(stderr, "Failed to allocate the mapping: %s\n",
    modbus_strerror(errno));
    modbus_free(ctx);
    return -1;
  }
  
  s = modbus_tcp_listen(ctx, 1);
  modbus_tcp_accept(ctx, &s);
  
  for (;;) {
    uint8_t query[MODBUS_TCP_MAX_ADU_LENGTH];
    int rc;
    
    rc = modbus_receive(ctx, query);
    printf("SLAVE: regs[] =\t");
    for(i = 1; i != 11; i++) { // looks like 1..n index
      printf("%d ", mb_mapping->tab_registers[i]);
    }
    printf("\n");
    
    if (rc > 0) {
      /* rc is the query size */
      modbus_reply(ctx, query, rc, mb_mapping);
    } else if (rc == -1) {
      /* Connection closed by the client or error */
      break;
    }
  }
  
  printf("Quit the loop: %s\n", modbus_strerror(errno));
  
  if (s != -1) {
    close(s);
  }
  modbus_mapping_free(mb_mapping);
  modbus_close(ctx);
  modbus_free(ctx);
  
  return 0;
}

[링크 : https://github.com/pjmaker/libmodbus-wee-example/blob/master/slave.c]

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

libmodbus 예제 프로그램  (0) 2022.05.04
libmodbus tcp 예제  (0) 2022.05.04
modbus tcp 테스트 툴  (0) 2022.05.03
modbus tcp library  (0) 2022.04.25
modbus 프로토콜  (0) 2015.09.16
Posted by 구차니

윈도우용 바이너리는 하나인데. 아마 32비트일 것 같고

linux용 바이너리는 arm/aarch64/x86/x64 용을 제공한다.

 

modbus TCP 라고해서 slave Address가 사라지는건 아닌가 보네

-m tcp        MODBUS/TCP protocol (default otherwise)
-a #          Slave address (1-255 for serial, 0-255 for TCP, 1 is default)\n
-r #          Start reference (1-65536, 1 is default)
-c #          Number of values to read (1-125, 1 is default), optional for writing (use -c 1 to force FC5 or FC6)

 

GUI는 아니지만 license가 일반적인 사용에는 완전 free 라서 유용하게 쓸 수 있을 지도 모르겠다

[링크 : https://www.modbusdriver.com/modpoll.html]

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

libmodbus 예제 프로그램  (0) 2022.05.04
libmodbus tcp 예제  (0) 2022.05.04
libmodbus  (0) 2022.05.03
modbus tcp library  (0) 2022.04.25
modbus 프로토콜  (0) 2015.09.16
Posted by 구차니

이래서 키넥트 게임이 인식이 구렸던 건가 -_-

뒤에 배경이 깔금하지 않고 거리가 많이 떨어지지 않은 것도 있긴 하지만

아무것도 없는 옷이나 배경에 사람으로 인식해버리니..

약 10년 전 기술이라 대단하면서도 어쩔수 없는 건가..

 

libfreenect는 저수준 드라이버라 고수준 드라이버 기능인 뼈대 추적 기능을 지원하지 않는 듯? 

Does libfreenect have any skeleton tracking feature?

  • Skeleton tracking is higher-level than drivers and libfreenect is basically a low-level driver within OpenKinect. The raw data is made available and a skeleton-tracking solution that takes data from libfreenect can be built. The project Roadmap calls for further developments as the focus should change at some point from low-level driver and API to higher level abstractions

[링크 : https://openkinect.org/wiki/FAQ#Does_libfreenect_have_any_skeleton_tracking_feature.3F]

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

kinect2 도착  (0) 2024.06.20
오늘의 충동구매 kinect v2 for windows  (0) 2024.06.19
kinect 윈도우 vs 리눅스  (0) 2022.05.02
freenect on mac 실패  (0) 2022.04.28
kinect + rpi + ros = slam  (0) 2022.04.27
Posted by 구차니

freenect 예제가 kinect SDK의 예제보다 입체정확도가 많이 떨어진다.

그게 드라이버의 데이터 파싱 능력의 차이인지

아니면 예제 프로그램의 처리 차이인진 모르겠지만 말이다.

 

그리고 kinect 시점으로는 libfreenect 쪽의 화면이 정상적인 것으로 보이고

윈도우 쪽은 좌우가 반전된 것으로 보인다. 무슨 옵션이 있으려나?

 

 

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

오늘의 충동구매 kinect v2 for windows  (0) 2024.06.19
kinect skeleton tracking  (0) 2022.05.02
freenect on mac 실패  (0) 2022.04.28
kinect + rpi + ros = slam  (0) 2022.04.27
azure kinect  (0) 2022.04.27
Posted by 구차니
파일방2022. 5. 2. 10:13

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

rufus - symbol 'grub_register_command_lockdown' not found  (0) 2022.06.27
codesys  (0) 2022.05.18
ansi to html  (1) 2022.03.31
mscgen  (0) 2022.03.17
android userland ubuntu  (0) 2022.03.03
Posted by 구차니
Apple2022. 5. 1. 16:59

이건 차라리 윈도우가 단축키로 더 편한 느낌

전체화면 아이콘에 커서를 1초 이상 대고 있으면 아래와 같이 왼쪽/오른쪽에 배치가 있다.

[링크 : https://support.apple.com/ko-kr/HT204948]

'Apple' 카테고리의 다른 글

맥은 맥이다. (mac is NOT LINUX)  (0) 2022.05.29
.DS_Store 파일 생성 막기  (0) 2022.05.28
맥 멀티 모니터 설정  (0) 2022.05.01
macos opengl(cocoa?)  (0) 2022.04.28
dylib  (0) 2022.04.27
Posted by 구차니
Apple2022. 5. 1. 16:14

창고 뒤지다가 mini DP to HDMI 발견.

이전에 서피스 3 에서 사용하던 건데 쓸 데가 없어서 봉인 당해있다가 이제야 풀려났네

 

맥에 연결하니 모니터 복제로만 작동해서 당황..

검색해도 정렬이 안나와서 또 당황

아무튼 시스템 환경설정 - 디스플레이를 종료했다가 다시 실행하니 이제야 뜬다.

"디스플레이 미러링" 에 체크가 되어있어서 발생한 문제니

해제하면 문제없이 내부/외부 모니터 별도로 설정이 가능해진다.

그리고 다행히 티비로도 오디오가 잘 나온다.

[링크 : https://onna.kr/281]

'Apple' 카테고리의 다른 글

.DS_Store 파일 생성 막기  (0) 2022.05.28
mac 창 분할 사용하기  (0) 2022.05.01
macos opengl(cocoa?)  (0) 2022.04.28
dylib  (0) 2022.04.27
macos 한영 변환 단축키 변경  (0) 2022.04.07
Posted by 구차니

장인어른댁 컴퓨터 문제가 되서 확인해보니

cpu 문제 없음

ram 문제 없음

파워 문제 없음

메인보드 운명하셨습니다.

 

밤 11시에 약속잡고 1시간 가량 차를 끌고 가서 업어와서 수리하고 끝!

'개소리 왈왈 > 육아관련 주저리' 카테고리의 다른 글

노트5 파괴!  (0) 2022.05.06
어린이날  (0) 2022.05.05
장모님댁  (0) 2022.04.29
신속항원 검사  (0) 2022.04.17
짧은 주말  (0) 2022.04.16
Posted by 구차니

컴퓨터 고장 ㅠㅠ

'개소리 왈왈 > 육아관련 주저리' 카테고리의 다른 글

어린이날  (0) 2022.05.05
메인보드 구매, 교체  (0) 2022.04.30
신속항원 검사  (0) 2022.04.17
짧은 주말  (0) 2022.04.16
하루 종일 골골골  (0) 2022.04.10
Posted by 구차니