Beamlib 3.5.2
This is the Beam C++ class library.
Loading...
Searching...
No Matches
BoapMc1.h
Go to the documentation of this file.
1/*******************************************************************************
2 * BoapMc1.h BoapMc1 RPC protocol
3 * T.Barnaby, BEAM Ltd, 2018-06-21
4 * Copyright (c) 2022 All Right Reserved, Beam Ltd, https://www.beam.ltd.uk
5 * For license see LICENSE.txt at the root of the beamlib source tree.
6 *******************************************************************************
7 */
8#ifndef BoapMc1_h
9#define BoapMc1_h
10
11#include <BTypes.h>
12#include <BMutex.h>
13#include <BSemaphore.h>
14#include <BQueue.h>
15#include <BFifo.h>
16#include <BComms.h>
17
18// Main BOAP Types
19const BUInt16 BoapMc1Magic = 0x5542;
21
24public:
25 BoapMc1ApiVer(BUInt32 version = 0);
27 operator BUInt32();
28
29public:
32} __attribute__((aligned(4),packed));
33
34// BoapMc1 packet header
44
45// BoapMc1 packet
47public:
49 char data[8];
50} __attribute__((aligned(8),packed));
51
54 char string[32];
55} __attribute__((aligned(8),packed));
56
58 return ((len + 3) & ~3);
59}
60
61/*******************************************************************************
62 * Base for bidirectional communications objects
63 *******************************************************************************
64 */
65
118
119
120#endif
int16_t BInt16
Definition BTypes.h:21
uint16_t BUInt16
Definition BTypes.h:22
BUInt32 BUInt
Definition BTypes.h:33
uint32_t BUInt32
Definition BTypes.h:24
bool Bool
Definition BTypes.h:18
BUInt16 addressTo
Address to send to.
Definition BoapMc1.h:2
BUInt16 cmd
The RPC command or reply number.
Definition BoapMc1.h:4
BUInt32 boapMc1CommsRoundupLen(BUInt32 len)
Definition BoapMc1.h:57
class BoapMc1Comms __attribute__
BUInt16 addressFrom
Address packet is from.
Definition BoapMc1.h:3
const BUInt16 BoapMc1Magic
Definition BoapMc1.h:19
BoapMc1Type
Definition BoapMc1.h:20
@ BoapMc1TypeReply
Definition BoapMc1.h:20
@ BoapMc1TypeRequest
Definition BoapMc1.h:20
char data[8]
Definition BoapMc1.h:2
A base class for communications classes having a generic API.
Definition BComms.h:17
A chunk of data allowing writes of multiple chunks of segmented data.
Definition BTypes.h:94
Error return class. This class is used to return the error status from a function....
Definition BError.h:31
Mutex class. Note these are recursive Mutexes and so you need to make sure the number of unlocks equa...
Definition BMutex.h:14
Base Semaphore class.
Definition BSemaphore.h:16
BoapMc1 API version.
Definition BoapMc1.h:23
BoapMc1ApiVer(BUInt32 version=0)
Definition BoapMc1.cpp:44
BUInt16 maj
The major version component.
Definition BoapMc1.h:31
BUInt16 mid
The mid version component.
Definition BoapMc1.h:30
Definition BoapMc1.h:66
BMutex olockCall
Lock for RPC calls. Only one at a time.
Definition BoapMc1.h:100
virtual BError processRequests()
Check and process any requests.
Definition BoapMc1.cpp:288
BSemaphore opacketRpcSema
Wait RPC reply semaphore.
Definition BoapMc1.h:114
BSemaphore opacketRpcDoneSema
Wait RPC complete semaphore.
Definition BoapMc1.h:115
virtual BError validate()
Validate the request.
Definition BoapMc1.cpp:109
void setAddress(BUInt16 addressTo, BUInt16 addressFrom)
Sets the to and from addresses.
Definition BoapMc1.cpp:92
BoapMc1ApiVer oapiVersion
The API version major.
Definition BoapMc1.h:103
BUInt32 oreqSize
The maximum request size.
Definition BoapMc1.h:99
BError packetTx(BDataChunk *chunks, BUInt nChunks, BUInt16 waitCmdReply)
Definition BoapMc1.cpp:117
BoapMc1Packet * packetRx()
Returns a reference to the current RX packet.
Definition BoapMc1.cpp:113
BoapMc1Packet * opacketTx
The TX packet.
Definition BoapMc1.h:112
virtual BError processRequest()
Check and process any request.
Definition BoapMc1.cpp:276
void setCommsMode(Bool halfDuplex)
Sets half duplex mode.
Definition BoapMc1.cpp:80
BComms * ocomms
Definition BoapMc1.h:102
virtual ~BoapMc1Comms()
Definition BoapMc1.cpp:77
BMutex olockTx
Lock for TX.
Definition BoapMc1.h:101
virtual BError processRx()
Process any RX packets queuing them as needed.
Definition BoapMc1.cpp:195
BoapMc1Packet opacketRxBase
Definition BoapMc1.h:109
BUInt32 setTimeout(BUInt32 timeoutUs)
Sets the call timeout returning the current value.
Definition BoapMc1.cpp:101
Bool othreaded
Threaded operation.
Definition BoapMc1.h:98
BUInt16 oaddressFrom
Definition BoapMc1.h:107
BoapMc1ApiVer getApiVersion()
Returns the API version.
Definition BoapMc1.cpp:97
BoapMc1Packet * opacketRx
The RX packet.
Definition BoapMc1.h:110
BError packetRxEnd()
Definition BoapMc1.cpp:186
Bool ohalfDuplex
Half duplex mode.
Definition BoapMc1.h:104
BUInt opacketRpcCmd
Waiting for RPC reply to cmd.
Definition BoapMc1.h:113
void setComms(BComms &comms)
Sets the communications interface to use.
Definition BoapMc1.cpp:84
BUInt16 oaddressTo
Definition BoapMc1.h:106
BoapMc1Packet opacketTxBase
Definition BoapMc1.h:111
BError packetRxData(void *data, BUInt nBytes)
Definition BoapMc1.cpp:164
BoapMc1Comms(Bool threaded=0, BUInt reqSize=512)
Definition BoapMc1.cpp:63
BUInt32 otimeout
The timeout in us for calls.
Definition BoapMc1.h:105
BoapMc1Error oerror
The call return error;.
Definition BoapMc1.h:116
Definition BoapMc1.h:46
char data[8]
Definition BoapMc1.h:49
BoapMc1PacketHead head
Definition BoapMc1.h:48
Definition BoapMc1.h:52
BInt16 number
The error number.
Definition BoapMc1.h:53
Definition BoapMc1.h:35
BInt16 error
Error number.
Definition BoapMc1.h:41
BUInt16 addressFrom
Address packet is from.
Definition BoapMc1.h:39
BUInt16 magic
Packet magic pattern.
Definition BoapMc1.h:36
BUInt16 addressTo
Address to send to.
Definition BoapMc1.h:38
BUInt16 cmd
The RPC command or reply number.
Definition BoapMc1.h:40
BUInt32 checksum
Packet checksum, when used.
Definition BoapMc1.h:42
BUInt16 length
Total packet length including the header.
Definition BoapMc1.h:37