---
name: "BRLPACKET_LEAVETTY"
section: "3"
platform: "linux"
package: "libbrlapi-dev"
version: "3.4.1-4"
release: "Debian 3.1 (Sarge)"
platforms: ["linux"]
url: "https://new.carta.tech/brlapi_protocol"
---

# BRLPACKET\_LEAVETTY(3)

Instructions and constants for BrlAPI 's protocol.

Part of [brlapi\_protocol(3)](/brlapi_protocol/3.md).

## NAME

BrlAPI's protocol - Instructions and constants for *BrlAPI* 's protocol.

### Defines

\#define **BRLAPI\_MAXPACKETSIZE**   512\
 \#define **BRLPACKET\_AUTHKEY**   'K'\
 \#define **BRLPACKET\_BYE**   'B'\
 \#define **BRLPACKET\_GETDRIVERID**   'd'\
 \#define **BRLPACKET\_GETDRIVERNAME**   'n'\
 \#define **BRLPACKET\_GETDISPLAYSIZE**   's'\
 \#define **BRLPACKET\_GETTTY**   't'\
 \#define **BRLPACKET\_LEAVETTY**   'L'\
 \#define **BRLPACKET\_KEY**   'k'\
 \#define **BRLPACKET\_COMMAND**   'c'\
 \#define **BRLPACKET\_MASKKEYS**   'm'\
 \#define **BRLPACKET\_UNMASKKEYS**   'u'\
 \#define **BRLPACKET\_WRITE**   'W'\
 \#define **BRLPACKET\_WRITEDOTS**   'D'\
 \#define **BRLPACKET\_STATWRITE**   'S'\
 \#define **BRLPACKET\_GETRAW**   '\*'\
 \#define **BRLPACKET\_LEAVERAW**   '#'\
 \#define **BRLPACKET\_PACKET**   'p'\
 \#define **BRLPACKET\_ACK**   'A'\
 \#define **BRLPACKET\_ERROR**   'E'\
 \#define **BRLRAW\_MAGIC**   (0xdeadbeefL)\

### Typedefs

typedef uint32\_t **brl\_type\_t**\

### Functions

int **brlapi\_writePacket** (int fd, **brl\_type\_t** type, const void \*buf, size\_t size)\
 int **brlapi\_readPacket** (int fd, **brl\_type\_t** \*type, void \*buf, size\_t size)\

### Variables

pthread\_mutex\_t **brlapi\_fd\_mutex**\

## Detailed Description

These are defines for the protocol between *BrlAPI* 's server and clients. Understanding is not needed to use the *BrlAPI* library, so reading this is not needed unless really wanting to connect to *BrlAPI* without *BrlAPI* 's library.

## Define Documentation

### #define BRLAPI\_MAXPACKETSIZE 512

Maximum packet size for packets exchanged on sockets and with braille terminal

### #define BRLPACKET\_ACK 'A'

Acknowledgement

### #define BRLPACKET\_AUTHKEY 'K'

Authentication key

### #define BRLPACKET\_BYE 'B'

Bye

### #define BRLPACKET\_COMMAND 'c'

braille command

### #define BRLPACKET\_ERROR 'E'

Error in protocol

### #define BRLPACKET\_GETDISPLAYSIZE 's'

Dimensions of brl display

### #define BRLPACKET\_GETDRIVERID 'd'

Ask which driver is used

### #define BRLPACKET\_GETDRIVERNAME 'n'

Ask which driver is used

### #define BRLPACKET\_GETRAW '\*'

Enter in raw mode

### #define BRLPACKET\_GETTTY 't'

asks for a specified tty

### #define BRLPACKET\_KEY 'k'

braille key

### #define BRLPACKET\_LEAVERAW '#'

Leave raw mode

### #define BRLPACKET\_LEAVETTY 'L'

release the tty

### #define BRLPACKET\_MASKKEYS 'm'

Mask a key-range

### #define BRLPACKET\_PACKET 'p'

Raw packets

### #define BRLPACKET\_STATWRITE 'S'

Write Status Cells

### #define BRLPACKET\_UNMASKKEYS 'u'

Unmask key range

### #define BRLPACKET\_WRITE 'W'

Write On Braille Display

### #define BRLPACKET\_WRITEDOTS 'D'

Write Dots On Braille Display

### #define BRLRAW\_MAGIC (0xdeadbeefL)

Magic number to give when sending a BRLPACKET\_GETRAW packet

## Typedef Documentation

### typedef uint32\_t brl\_type\_t

type for packet type. Only unsigned can cross networks, 32bits

## Function Documentation

### int brlapi\_readPacket (int fd, brl\_type\_t \* type, void \* buf, size\_t size)

Read a packet from *BrlAPI* server

This function is for internal use, but one might use it if one really knows what one is doing...

*type* is where the function will store the packet type; it should always be one of the above defined BRLPACKET\_\* (or else something very nasty must have happened :/).

The syntax is the same as read()'s.

**Returns:**

packet's size, -2 if `EOF` occurred, -1 on error

### int brlapi\_writePacket (int fd, brl\_type\_t type, const void \* buf, size\_t size)

Send a packet to *BrlAPI* server

This function is for internal use, but one might use it if one really knows what one is doing...

*type* should only be one of the above defined BRLPACKET\_\*.

The syntax is the same as write()'s.

**Returns:**

0 on success, -1 on failure

## Variable Documentation

### pthread\_mutex\_t brlapi\_fd\_mutex

Mutex for protecting concurrent fd access

In order to regulate concurrent access to the library's file descriptor and requests to / answers from *BrlAPI* server, every function of the library locks this mutex, namely

- •

  **brlapi\_initializeConnection()**

- •

  **brlapi\_closeConnection()**

- •

  **brlapi\_getRaw()**

- •

  **brlapi\_leaveRaw()**

- •

  **brlapi\_sendRaw()**

- •

  **brlapi\_recvRaw()**

- •

  **brlapi\_getDriverId()**

- •

  **brlapi\_getDriverName()**

- •

  **brlapi\_getDisplaySize()**

- •

  **brlapi\_getTty()**

- •

  **brlapi\_leaveTty()**

- •

  brlapi\_write\*()

- •

  brlapi\_(un)?ignorekeys()

- •

  brlapi\_read\*()

If both these functions and **brlapi\_writePacket()** or **brlapi\_readPacket()** are used in a multithreaded application, this mutex must be locked before calling **brlapi\_writePacket()** or **brlapi\_readPacket()**, and unlocked afterwards.
