pocketbus.h File Reference

Basical functions to use pocketBus protocol. More...

#include "cfg/cfg_pocketbus.h"
#include <cfg/compiler.h>
#include <algo/rotating_hash.h>
#include <kern/kfile.h>

Go to the source code of this file.

Data Structures

struct  PocketBusHdr
 Header of pocketBus messages. More...
struct  PocketBusCtx
 pocketBus context structure. More...
struct  PocketMsg
 Structure holding pocketBus message parameters. More...

Defines

#define POCKETBUS_BROADCAST_ADDR   0xFFFF
 pocketBus broadcast address

#define POCKETBUS_STX   0x02
 pocketBus special characters definitions.

Typedefs

typedef uint16_t pocketbus_len_t
 Type for pocketBus length.
typedef uint16_t pocketbus_addr_t
 Type for pocketBus addresses.
typedef struct PocketBusHdr PocketBusHdr
 Header of pocketBus messages.
typedef struct PocketBusCtx PocketBusCtx
 pocketBus context structure.
typedef struct PocketMsg PocketMsg
 Structure holding pocketBus message parameters.

Functions

void pocketbus_putchar (struct PocketBusCtx *ctx, uint8_t c)
 Send a character over pocketBus channel stream, handling escape mode.
void pocketbus_begin (struct PocketBusCtx *ctx, pocketbus_addr_t addr)
 Send pocketBus packet header.
void pocketbus_write (struct PocketBusCtx *ctx, const void *_data, size_t len)
 Send buffer _data over bus, handling escape.
void pocketbus_end (struct PocketBusCtx *ctx)
 Send pocketBus packet tail.
void pocketbus_send (struct PocketBusCtx *ctx, pocketbus_addr_t addr, const void *data, size_t len)
 Send buffer of data to address addr with a pocketBus packet over channel stream.
bool pocketbus_recv (struct PocketBusCtx *ctx, struct PocketMsg *msg)
 Try to read a packet from the pocketBus.
void pocketbus_init (struct PocketBusCtx *ctx, struct KFile *fd)
 Initialize pocketBus protocol handler.

 STATIC_ASSERT (sizeof(pocketbus_addr_t)==sizeof(uint16_t))
 This ensure that endianess convertion functions work on the right data size.

Detailed Description

Basical functions to use pocketBus protocol.

Version:
Id
pocketbus.h 2830 2009-08-31 15:13:33Z asterix
Author:
Francesco Sacchi <batt@develer.com>

Definition in file pocketbus.h.


Function Documentation

bool pocketbus_recv ( struct PocketBusCtx ctx,
struct PocketMsg msg 
)

Try to read a packet from the pocketBus.

Returns:
true if a packet is received, false otherwise.

Definition at line 171 of file pocketbus.c.