First draft

This commit is contained in:
2025-11-07 15:57:11 +00:00
commit f306df9daf
13 changed files with 502 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
#include "asn1_wrapper.h"
err_t incp_decode_header(BitStream *in_bs, IncpMsg *msg)
{
int asn1_err = 0;
if (!IncpMsg_Decode(msg, in_bs, &asn1_err))
return ERR_ERROR; //TODO: Proper error setting based on asn1_err
return ERR_SUCCESS;
}

View File

@@ -0,0 +1,23 @@
// asn1_wrapper.h - Wraps all ASN.1 generated files to conform with the rest of the C interface (return type to err_t
// and alike).
// Should only be used inside INCP implementation.
#pragma once
#ifndef _INCP_INTERNAL
#error "asn1_wrapper.h should not be imported outside the implementation of INCP"
#endif
#include "incp2.h"
#include "messaging.h"
#include "out/incp_static.h"
typedef IncpMsg_selection incp_msgt_t;
err_t incp_encode_header(BitStream *bs, IncpMsg *msg);
err_t incp_decode_header(BitStream *bs, IncpMsg *msg);
err_t incp_encode_datareq(BitStream *bs, U32 id);
err_t incp_decode_datareq(BitStream *bs, U32 id);
err_t incp_encode_dataret(BitStream *bs, AnyData *data);
err_t incp_decode_dataret(BitStream *bs, AnyData *data);

View File

@@ -0,0 +1,19 @@
INCP-Generated DEFINITIONS AUTOMATIC TAGS ::= BEGIN
EXPORTS ALL;
IMPORTS U32 FROM INCP-Types;
TTC-TxTotal ::= SEQUENCE {
bytes U32
}
TTC-RxTotal ::= SEQUENCE {
bytes U32
}
AnyData ::= CHOICE {
ttcTxTotal TTC-TxTotal,
ttcRxTotal TTC-RxTotal
}
END

View File

@@ -0,0 +1,51 @@
INCP-Types DEFINITIONS AUTOMATIC TAGS ::= BEGIN
EXPORTS ALL;
U8 ::= INTEGER(0..255)
U16 ::= INTEGER(0..65535)
U24 ::= INTEGER(8388608..16777215)
U32 ::= INTEGER(0..4294967295)
U64 ::= INTEGER(0..18446744073709551615)
I8 ::= INTEGER(-128..127)
I16 ::= INTEGER(-32768..32767)
I24 ::= INTEGER(-8388608..8388607)
I32 ::= INTEGER(-2147483648..2147483647)
END
INCP-Static DEFINITIONS AUTOMATIC TAGS ::= BEGIN
IMPORTS U8, U16, U32 FROM INCP-Types
AnyData FROM INCP-Generated;
PingMsg ::= SEQUENCE {
payload SEQUENCE (SIZE(32)) OF U8
}
DataReqMsg ::= SEQUENCE {
id U32 -- REVIEW: How to limit range to only accept IDs that are valid
}
DataRetMsg ::= SEQUENCE {
data AnyData
}
CommandReqMsg ::= SEQUENCE {
id U16
}
CommandRetMsg ::= SEQUENCE {
id U16
}
IncpMsg ::= CHOICE {
ping PingMsg,
pong PingMsg,
dataReq DataReqMsg,
dataRet DataRetMsg,
commandReq CommandReqMsg,
commandRet CommandRetMsg
}
END