Please enable JavaScript to view this site.

This function writes the bits of a specified HOLDING REGISTER to a modbus server.

Syntax

i32 mbc_mask_write_reg (i32 mbc, i32 offsHRStart, i32 endian, i32 bitMsk, i32 bitVal)

mbc

Handle value returned by mbc_init()

offsHRStart

Initial index of the HOLDING REGISTER

endian

Type of endian to be used:

Value

Meaning

0 [EM_B_16]

Big Endian in the single word. (default)

1 [EM_L_16]

Little Endian in the single word

2 [EM_B_32]

Big Endian in 32 bits

3 [EM_L_32]

Little Endian in 32 bits

4 [EM_MB_32]

Middle Big Endian in 32 bits

5 [EM_ML_32]

Middle little Endian in 32 bits

6 [EM_B_64]

Big Endian in 64 bit

7 [EM_L_64]

Little Endian in 64 bit

8 [EM_MB_64]

Middle Big Endian in 64 bit

9 [EM_ML_64]

Middle little Endian in 64 bit

bitMsk

Mask of the bits that have to be written.

Note: The mask must have the affected bits in 1 (R3-style, as opposed to what modbus wants instead).

result = (result r_and r_not bitMsk) r_or (bitVal r_and bitMsk)

bitVal

Mask containing the state of the affected bits

Result

Returns:

Value

Meaning

0 [MBC_OK]

Command executed

-1 [MBC_INVAL]

Invalid arguments

-2 [MBC_BUSY]

Resource occupied

-3 [MBC_PERM]

Permission denied

-4 [MBC_CONN]

Connection failed

-5 [MBC_NOBUFS]

Buffer exhausted

-6 [MBC_NOMEM]

Insufficient memory

-7 [MBC_TX_ERR]

Transmission error

-8 [MBC_RX_ERR]

Receive error

-9 [MBC_TIMEOUT]

Blocking command timeout

-10 [MBC_EXC_CODE_1]

Response with exception 1 (function code not supported by the server)

-11 [MBC_EXC_CODE_2]

Response with exception 2 (invalid address)

-12 [MBC_EXC_CODE_3]

Response with exception 3 (invalid quantity or value)

-13 [MBC_EXC_CODE_4]

Response with exception 4 (operation failed)

-14 [MBC_WRONG_ANSWER]

Invalid response

-15 [MBC_INVAL_MBC]

Invalid mbc id

Validity

Task

Note

The function is blocking. It exits only when the operation has been completed

 

  

Keyboard Navigation

F7 for caret browsing
Hold ALT and press letter

This Info: ALT+q
Page Header: ALT+h
Topic Header: ALT+t
Topic Body: ALT+b
Contents: ALT+c
Search: ALT+s
Exit Menu/Up: ESC