'프로그램 사용'에 해당되는 글 2388건

  1. 2022.06.08 weston desktop-shell output destory
  2. 2022.06.02 gcc vectorization 실패
  3. 2022.05.27 sdl tutorial
  4. 2022.05.24 blender on macos
  5. 2022.05.22 big bunny blender project file
  6. 2022.05.17 ncurse example
  7. 2022.05.10 libmodbus pi 함수들
  8. 2022.05.10 libmodbus modbus_mapping_new()
  9. 2022.05.04 libmodbus poll 적용
  10. 2022.05.04 modbus tcp

drm 에서 HDMI hotplug를 아래 코드에서 처리하는데 shell로 어떻게 넘겨주는진 발견하지 못했다.

static int
udev_drm_event(int fd, uint32_t mask, void *data)
{
struct drm_backend *b = data;
struct udev_device *event;
uint32_t conn_id, prop_id;

event = udev_monitor_receive_device(b->udev_monitor);

if (udev_event_is_hotplug(b, event)) {
if (udev_event_is_conn_prop_change(b, event, &conn_id, &prop_id))
drm_backend_update_conn_props(b, conn_id, prop_id);
else
drm_backend_update_heads(b, event);
}

udev_device_unref(event);

return 1;
}

static void
drm_backend_update_heads(struct drm_backend *b, struct udev_device *drm_device)
{
/* collect new connectors that have appeared, e.g. MST */
for (i = 0; i < resources->count_connectors; i++) {
uint32_t connector_id = resources->connectors[i];

head = drm_head_find_by_connector(b, connector_id);
if (head) {
drm_head_update_info(head);
} else {
head = drm_head_create(b, connector_id, drm_device);
if (!head)
weston_log("DRM: failed to create head for hot-added connector %d.\n",
   connector_id);
}
}
}

static void
drm_head_update_info(struct drm_head *head)
{
drmModeConnector *connector;

connector = drmModeGetConnector(head->backend->drm.fd,
head->connector_id);
if (!connector) {
weston_log("DRM: getting connector info for '%s' failed.\n",
   head->base.name);
return;
}

if (drm_head_assign_connector_info(head, connector) < 0)
drmModeFreeConnector(connector);

if (head->base.device_changed)
drm_head_log_info(head, "updated");
}

static void
drm_head_log_info(struct drm_head *head, const char *msg)
{
if (head->base.connected) {
weston_log("DRM: head '%s' %s, connector %d is connected, "
   "EDID make '%s', model '%s', serial '%s'\n",
   head->base.name, msg, head->connector_id,
   head->base.make, head->base.model,
   head->base.serial_number ?: "");
} else {
weston_log("DRM: head '%s' %s, connector %d is disconnected.\n",
   head->base.name, msg, head->connector_id);
}
}

 

다만.. 아래의 코드에서 등록되어 output이 파괴될때 트리거 되어 작동하는 녀석만 발견함.

static void
handle_output_destroy(struct wl_listener *listener, void *data);

static void
create_shell_output(struct desktop_shell *shell,
struct weston_output *output)
{
struct shell_output *shell_output;

shell_output = zalloc(sizeof *shell_output);
if (shell_output == NULL)
return;

shell_output->output = output;
shell_output->shell = shell;
shell_output->destroy_listener.notify = handle_output_destroy;
wl_signal_add(&output->destroy_signal,
      &shell_output->destroy_listener);
wl_list_insert(shell->output_list.prev, &shell_output->link);

if (wl_list_length(&shell->output_list) == 1)
shell_for_each_layer(shell,
     shell_output_changed_move_layer, NULL);
}

static void
handle_output_create(struct wl_listener *listener, void *data)
{
struct desktop_shell *shell =
container_of(listener, struct desktop_shell, output_create_listener);
struct weston_output *output = (struct weston_output *)data;

create_shell_output(shell, output);
}


static void
setup_output_destroy_handler(struct weston_compositor *ec,
struct desktop_shell *shell)
{
struct weston_output *output;

wl_list_init(&shell->output_list);
wl_list_for_each(output, &ec->output_list, link)
create_shell_output(shell, output);

shell->output_create_listener.notify = handle_output_create;
wl_signal_add(&ec->output_created_signal,
&shell->output_create_listener);

shell->output_move_listener.notify = handle_output_move;
wl_signal_add(&ec->output_moved_signal, &shell->output_move_listener);
}

WL_EXPORT int
wet_shell_init(struct weston_compositor *ec,
       int *argc, char *argv[])
{
setup_output_destroy_handler(ec, shell);
}

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

libwayland debug 메시지  (0) 2022.06.27
libwayland  (0) 2022.06.27
weston debug message  (0) 2022.03.18
weston drm atomic  (0) 2022.03.17
wayvnc 실행 실패  (0) 2022.02.17
Posted by 구차니
프로그램 사용/gcc2022. 6. 2. 14:47

아래 에러들은 SIMD 명령으로 변환하는데 실패한 녀석들인것 같은데

아래와 같은 유형들이 에러로 발생했다.

 

반복문이 중첩되거나, 반복문 내에서 조건문이 있으면 안되는 것 같고

tt.c:180:3: note: ===== analyze_loop_nest =====
tt.c:180:3: note: === vect_analyze_loop_form ===
tt.c:180:3: note: not vectorized: control flow in loop.
tt.c:180:3: note: bad loop form.


tt.c:61:3: note: ===== analyze_loop_nest =====
tt.c:61:3: note: === vect_analyze_loop_form ===
tt.c:61:3: note: not vectorized: multiple nested loops.
tt.c:61:3: note: bad loop form.

 

아래부터는 어떤 에러인지 감이 안오는 녀석들..

지원하지 않는 패턴

tt.c:83:7: note: Unsupported pattern.
tt.c:83:7: note: not vectorized: unsupported use in stmt.
tt.c:83:7: note: unexpected pattern.

 

지원되지 않는 데이터 타입. 코드를 보니 for문의 비교문에

함수 포인터를 통한 참조(->) 로 보려고 할때는 타입을 추적 못하는 듯?

tt.c:107:5: note: not vectorized: unsupported data-type
tt.c:107:5: note: can't determine vectorization factor.

 

no grouped store가 어떤건지 모르겠다.

val = data[];

out = data / 255;

이런식으로 단순화 가능한 코드인데 배열과 포인터로 배열 인자가 선형으로 분석될수 없기 때문에 그런걸지도?

tt.c:106:3: note: not vectorized: no grouped stores in basic block.
tt.c:106:3: note: ===vect_slp_analyze_bb===
tt.c:106:3: note: ===vect_slp_analyze_bb===
tt.c:108:32: note: === vect_analyze_data_refs ===
tt.c:108:32: note: not vectorized: not enough data-refs in basic block.

 

모르겠고..

tt.c:228:3: note: not vectorized: data ref analysis failed _47 = *_46;
tt.c:228:3: note: bad data references.

 

모르겠다!!!

tt.c:238:5: note: not vectorized: not suitable for gather load _47 = *_46;
tt.c:238:5: note: bad data references.

 

 

아무튼 AVX로도 변환이 안되는데 .. NEON으로 최적화 될만한 코드는 더더욱 아닐 것 같네.

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

gcc tree vectorize  (0) 2023.01.26
gcc fstack-protector-strong  (0) 2022.12.06
gcc / 문자열 선언  (0) 2022.03.17
static link  (0) 2022.02.07
구조체 타입과 변수명은 구분된다?  (0) 2021.11.18
Posted by 구차니
프로그램 사용/sdl2022. 5. 27. 23:35

mac에서 되나 궁금해서 검색. 된다고는 하는데 openGL deprecate 된대서 어떻게 될지 모르겠네

 

[링크 : https://github.com/MikeShah/SDL2_Tutorials]

[링크 : https://wiki.libsdl.org/Tutorials]

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

SDL - Simple DirectMedia Layer  (0) 2021.07.06
libsdl + mfc  (0) 2017.02.09
SDL - Simple DirectMedia Layer  (0) 2011.12.12
Posted by 구차니
프로그램 사용/Blender2022. 5. 24. 21:46

인스톨러 이쁘게 잘 만들었네

 

초기 메뉴에서 spacebar가 기본값이 재생인데 이경우에는 shift-space 로 도구를 띄우고

도구로 되어있으면 shift-space 가 재생으로 작동한다.

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

blender render node  (0) 2024.03.20
BGE / UPBGE(Blender game engine)  (0) 2023.10.20
big bunny blender project file  (0) 2022.05.22
블렌더 강좌? (유료)  (0) 2021.08.07
blender 포켓몬 애니메이션  (0) 2020.08.08
Posted by 구차니
프로그램 사용/Blender2022. 5. 22. 22:53

문득 블렌더 돌려보고 싶어서 다운로드 하다가

blender로 만든 동영상이 생각나서 다운로드 해두려고 검색

 

[링크 : http://bbb3d.renderfarming.net/explore.html]

[링크 : http://distribution.bbb3d.renderfarming.net/blender/blender.zip]

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

BGE / UPBGE(Blender game engine)  (0) 2023.10.20
blender on macos  (0) 2022.05.24
블렌더 강좌? (유료)  (0) 2021.08.07
blender 포켓몬 애니메이션  (0) 2020.08.08
blender physical simulation  (0) 2018.03.19
Posted by 구차니
프로그램 사용/ncurses2022. 5. 17. 08:17

make menuconfig 하면 먼가 그럴싸하게 그려주는게 ncurses 인데

라이브러리는 curses.h 이다. 찾아보니 New Curses 라서 ncurses라고..

[링크 : https://ko.wikipedia.org/wiki/Ncurses]

 

좌표만 주면 알아서 써주는 것 같은데

드래그 하면 창 크기 알아서 읽어서 박스 그리는건 어떻게 해야하려나?

/*

  CURHELLO.C
  ==========
  (c) Copyright Paul Griffiths 1999
  Email: mail@paulgriffiths.net

  "Hello, world!", ncurses style.

*/


#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>                  /*  for sleep()  */
#include <curses.h>


int main(void) {

    WINDOW * mainwin;

    
    /*  Initialize ncurses  */

    if ( (mainwin = initscr()) == NULL ) {
fprintf(stderr, "Error initialising ncurses.\n");
exit(EXIT_FAILURE);
    }


    /*  Display "Hello, world!" in the centre of the
screen, call refresh() to show our changes, and
sleep() for a few seconds to get the full screen effect  */

    mvaddstr(13, 33, "Hello, world!");
    refresh();
    sleep(3);


    /*  Clean up after ourselves  */

    delwin(mainwin);
    endwin();
    refresh();

    return EXIT_SUCCESS;
}

[링크 : https://www.paulgriffiths.net/program/c/srcs/curhellosrc.html]

[링크 : http://www.paulgriffiths.net/program/c/curses.php]

 

API
[링크 : https://tldp.org/HOWTO/NCURSES-Programming-HOWTO/index.html]

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

ncurse screen size  (0) 2025.09.30
ncurses 상자 및 색상 적용하기  (0) 2024.12.02
ncurses 예제  (0) 2024.11.30
ncurse  (0) 2015.04.27
Posted by 구차니

pi 라는 함수들이 있어서 찾아보니 코드로는 모르겠고

도움말에서 검색.. Protocol Independent. 무슨 의미이려나?

아무튼 메모리 1Kb 더 먹고 hostname resolve를 제공한다는 것 같은데(resolution은 또 머야..)

그 기능만 차이가 있다면 굳이 pi를 쓸 이유는 없을 듯

 

TCP (IPv4) Context

The TCP backend implements a Modbus variant used for communications over TCP/IPv4 networks. It does not require a checksum calculation as lower layer takes care of the same.
Create a Modbus TCP contextmodbus_new_tcp(3)

TCP PI (IPv4 and IPv6) Context

The TCP PI (Protocol Indepedent) backend implements a Modbus variant used for communications over TCP IPv4 and IPv6 networks. It does not require a checksum calculation as lower layer takes care of the same.
Contrary to the TCP IPv4 only backend, the TCP PI backend offers hostname resolution but it consumes about 1Kb of additional memory.
Create a Modbus TCP contextmodbus_new_tcp_pi(3)

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

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

mbpoll  (0) 2025.08.06
libmodbus backend  (0) 2025.03.13
libmodbus modbus_mapping_new()  (0) 2022.05.10
libmodbus poll 적용  (0) 2022.05.04
modbus tcp  (0) 2022.05.04
Posted by 구차니

함수는 간단한데.. 예제가 이상하게 만들어 놔서 헷갈렸네..

아무튼 modbus_mapping_new() 함수의 인자들은 

coil / discrete input / holding register / input register 에 대한 변수를 몇개까지 유지하냐에 대한 값을 받는다.

 

modbus_mapping_t modbus_mapping_new(int nb_bits, int nb_input_bits, int nb_registers, int nb_input_registers);

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

 

libmodbus의 test 에 생성된 unit-test.h 소스에서 추출하고

 29 const uint16_t UT_BITS_ADDRESS = 0x130;
 30 const uint16_t UT_BITS_NB = 0x25;
 31 const uint8_t UT_BITS_TAB[] = { 0xCD, 0x6B, 0xB2, 0x0E, 0x1B };
 32
 33 const uint16_t UT_INPUT_BITS_ADDRESS = 0x1C4;
 34 const uint16_t UT_INPUT_BITS_NB = 0x16;
 35 const uint8_t UT_INPUT_BITS_TAB[] = { 0xAC, 0xDB, 0x35 };
 36
 37 const uint16_t UT_REGISTERS_ADDRESS = 0x160;
 38 const uint16_t UT_REGISTERS_NB = 0x3;
 39 const uint16_t UT_REGISTERS_NB_MAX = 0x20;
 40 const uint16_t UT_REGISTERS_TAB[] = { 0x022B, 0x0001, 0x0064 };

 56 const uint16_t UT_INPUT_REGISTERS_ADDRESS = 0x108;
 57 const uint16_t UT_INPUT_REGISTERS_NB = 0x1;
 58 const uint16_t UT_INPUT_REGISTERS_TAB[] = { 0x000A };

 

최신 문서에서 보는데 오히려 더 헷갈린다.

/* The first value of each array is accessible from the 0 address. */
mb_mapping = modbus_mapping_new(BITS_ADDRESS + BITS_NB,
                                INPUT_BITS_ADDRESS + INPUT_BITS_NB,
                                REGISTERS_ADDRESS + REGISTERS_NB,
                                INPUT_REGISTERS_ADDRESS + INPUT_REGISTERS_NB);

[링크 : https://libmodbus.org/docs/v3.1.6/modbus_mapping_new.html]

-> [링크 : https://libmodbus.org/reference/modbus_mapping_new/] 2025.03.12

 

아래처럼 수정하고

        mb_mapping = modbus_mapping_new(10,10,10,10);

 

modbus poll 프로그램에서 아래와 같이 실제 설정된 크기보다 크게 읽도록 하니

 

illegal data address 라고 에러가 발생한다.

 

아무튼.. 메모리 시작 번지는 의미가 없고 그냥 0번지 부터 해당 크기 만큼 응답하게 되는 듯?

 

+

[링크 : https://www.codetd.com/ko/article/12030369]

[링크 : https://m.blog.naver.com/ssundong0_0/221385568015]

[링크 : https://intrepidgeeks.../libmodbus-source-code-analysis-1-basic-framework-key-data-structure-and-interface]

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

libmodbus backend  (0) 2025.03.13
libmodbus pi 함수들  (0) 2022.05.10
libmodbus poll 적용  (0) 2022.05.04
modbus tcp  (0) 2022.05.04
libmodbus 예제 프로그램  (0) 2022.05.04
Posted by 구차니

기본 소스를 사용해보면. modbus_receive() 에서 블록킹 된 상태라서 다른걸 할 수가 없다.

 

검색을 해보니 libmodbus issue 쪽에서 발견한 내용으로

poll 에서 확인이 되면 소켓을 modbus_set_socket() 함수를 이용하여 context에 연결하고 receive 하도록 구성되어 있다.

    modbus_t *ctx = modbus_new_tcp("0.0.0.0", port_);
    int server_socket = modbus_tcp_listen(ctx, 2);
    if (server_socket < 0) {
      // error handling
      modbus_free(ctx);
      return;
    }

          if (p->revents & POLLIN) {
            modbus_set_socket(ctx, p->fd); // set the socket to libmodbus answers to the right client

            uint8_t query[MODBUS_RTU_MAX_ADU_LENGTH];
            int rc = modbus_receive(ctx, query);
            if (rc <= 0) { // connection has been closed actually by the client
              ::close(p->fd);
              p = sockets.erase(p); // remove it from the poll-array
              continue;
            }

            /* rc is the query size */
            rc = modbus_reply_callback(ctx, query, rc); // handle the reply (via the callbacks)
            if (rc < 0) {
              // error handling - invalid request
              ::close(p->fd); // close client
              p = sockets.erase(p);
              continue;
            }
          }

[링크 : https://github.com/stephane/libmodbus/issues/173]

 

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

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

libmodbus pi 함수들  (0) 2022.05.10
libmodbus modbus_mapping_new()  (0) 2022.05.10
modbus tcp  (0) 2022.05.04
libmodbus 예제 프로그램  (0) 2022.05.04
libmodbus tcp 예제  (0) 2022.05.04
Posted by 구차니

modbus tcp의 MBAP(ModBus Application Protocol) 헤더(?)에는 아래와 같은 내용들이 들어있다.

 

[링크 : https://www.modbus.org/docs/Modbus_Messaging_Implementation_Guide_V1_0b.pdf]

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

 

Function Code (0x03) + start Address(0x0000) + quantity of regitster(0x0001)

         Protocol ID(0x0000 고정) 
                 Length   Function Code
00 01 00 00 00 06 03 03 00 00 00 01
                         Unit ID(0x01 고정) 
Transaction ID (시퀀셜 증가) 

 

-a로 tcp MBAP 상의 Unit ID를 변경할 순 있지만 ID=1 로 고정되어 있다고 하니 어떻게 처리를 해야 하려나?

$ sudo ./modpoll -m tcp localhost
00 01 00 00 00 06 01 03 00 00 00 01

$ sudo ./modpoll -m tcp -a 3 localhost
00 01 00 00 00 06 03 03 00 00 00 01

 

$ ./modpoll --help
modpoll 3.10 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2021 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.

Usage: modpoll [OPTIONS] SERIALPORT|HOST [WRITEVALUES...]
Arguments:
SERIALPORT    Serial port when using Modbus ASCII or Modbus RTU protocol
              COM1, COM2 ...                on Windows
              /dev/ttyS0, /dev/ttyS1 ...    on Linux
HOST          Host name or dotted IP address when using MDBUS/TCP protocol
WRITEVALUES   List of values to be written. If none specified (default) modpoll reads data.
General options:
-m ascii      Modbus ASCII protocol
-m rtu        Modbus RTU protocol (default if SERIALPORT contains a /)
-m tcp        MODBUS/TCP protocol (default otherwise)
-m udp        MODBUS UDP
-m enc        Encapsulated Modbus RTU over TCP
-a #          Slave address (1-247 for serial, 0-255 for TCP, 1 is default)
-r #          Start reference (1-65536, 100 is default)
-c #          Number of values to read (1-125, 1 is default), optional for writing (use -c 1 to force FC5 or FC6)
-t 0          Discrete output (coil) data type
-t 1          Discrete input data type
-t 3          16-bit input register data type
-t 3:hex      16-bit input register data type with hex display
-t 3:int      32-bit integer data type in input register table
-t 3:mod      32-bit module 10000 data type in input register table
-t 3:float    32-bit float data type in input register table
-t 4          16-bit output (holding) register data type (default)
-t 4:hex      16-bit output (holding) register data type with hex display
-t 4:int      32-bit integer data type in output (holding) register table
-t 4:mod      32-bit module 10000 type in output (holding) register table
-t 4:float    32-bit float data type in output (holding) register table
-i            Slave operates on big-endian 32-bit integers
-f            Slave operates on big-endian 32-bit floats
-e            Use Daniel/Enron single register 32-bit mode (implies -i and -f)
-0            First reference is 0 (PDU addressing) instead 1
-1            Poll only once only, otherwise every poll rate interval
-l #          Poll rate in ms, (1000 is default)
-o #          Time-out in seconds (0.01 - 10.0, 1.0 s is default)
Options for MODBUS/TCP, UDP and RTU over TCP:
-p #          IP protocol port number (502 is default)
Options for Modbus ASCII and Modbus RTU:
-b #          Baudrate (e.g. 9600, 19200, ...) (19200 is default)
-d #          Databits (7 or 8 for ASCII protocol, 8 for RTU)
-s #          Stopbits (1 or 2, 1 is default)
-p none       No parity
-p even       Even parity (default)
-p odd        Odd parity
-4 #          RS-485 mode, RTS on while transmitting and another # ms after

 

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

libmodbus modbus_mapping_new()  (0) 2022.05.10
libmodbus poll 적용  (0) 2022.05.04
libmodbus 예제 프로그램  (0) 2022.05.04
libmodbus tcp 예제  (0) 2022.05.04
libmodbus  (0) 2022.05.03
Posted by 구차니