Commit 8b0bcaf0 authored by Bernd-Christian Renner's avatar Bernd-Christian Renner
Browse files

initial open source commit

parents
BSD 3-Clause License
Copyright (c) 2019, smartport / public / ahoi
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# firmware
ahoi firmware sources
\ No newline at end of file
1.) Build dependencies
$ sudo apt install make cmake libusb-1.0.0-dev build-essential
2.) Documentation tools (optional)
$ sudo apt install doxygen doxygen-doc doxygen-gui graphviz
3.) GNU Tools for Arm Embedded Processors
We advice to use
GNU Arm Embedded Toolchain 7-2018-q2-update
from
https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
due to issues with other versions.
4.) STlink tools
$ git clone https://github.com/texane/stlink.git
$ cd stlink && make release && make debug && cd build/Release && sudo make install
5.) Modem firmware
$ git clone https://git.smp.tuhh.de/ahoi/firmware firmware
6.) Building
$ cd firmware
$ make t=<hardware platform> [tx=<tx board>]
hardware platforms:
- stm
- sim
tx boards:
- single
- bridge (default)
7.) Install firmware on modem (flashing)
- connect programming adapter to modem
- connect STlink-v2 programmer to programming adapter and PC
- power modem by external 12V (it is not powered through programmer)
- make t=stm [tx=<tx board>] program
OR
st-flash write <firmware-file.bin> 0x8000000, if you want to flash a release image
- if only the blue POWER LED is lid after flashing, restart the modem or remove programmer/programming adapter
(the top LED should be blinking as an indicator that the modem works properly)
8.) modem installation
- connect serial cable (FTDI 3V3) to modem and PC
- run MoSh and check that it responds to, e.g., a "version" command
- you have to set the ID of the modem (which is initially zero) by running "id <ID>"
(the ID will be stored in the EEPROM of the modem, so a restart with following "id" command via MoSh should produce the previously set ID (in hex format)
STM_MAKEFILE_PATH=hal/mcu/stm32f4/make/Makefile
STMOLD_MAKEFILE_PATH=hal/mcu/stm32f4-legacy/make/Makefile
SIM_MAKEFILE_PATH=hal/sim/make/Makefile
#ACI=./aci/aci-build.py
# ACI hack
#$(ACI)
export TXAMP=tx-bridge
ifeq ($(tx),single)
#FIXME changing the value here does *not* lead to a recompile!
TXAMP=tx-single
endif
export RXAMP=rx-gen3
#FIXME changing the value here does *not* lead to a recompile!
ifeq ($(rx),gen2)
RXAMP=rx-gen2
endif
ifeq ($(t),stm)
-include hal/mcu/stm32f4/make/config.mk
-include $(STM_MAKEFILE_PATH)
endif
ifeq ($(t),stm-legacy)
-include hal/mcu/stm32f4-legacy/make/config.mk
-include $(STMOLD_MAKEFILE_PATH)
endif
ifeq ($(t),sim)
-include hal/sim/make/config.mk
-include $(SIM_MAKEFILE_PATH)
endif
=== ACI ===
- processCmd should return bool? (valid or invalid command? or a return type?)
- send NACK(?), if command bad (maybe have different nack types or so; or an ACK with a return value)?
- or should be simply ignore wrong inputs and send the corresponding reponse (with unchanged values)
- reset cannot issue an ACK by the current flow design
- some responses MUST (by def) reflect the command (change?)
=== SEND / RECEIVE ARCHITECTURE ===
- convert to a layered approach (and not a sequential one)
- implement spreader as modular unit (w/o dependency of receive! [export/import mag])
=== SAMPLE ===
- change interface to number of symbols / or ms? Num samples just sucks!
=== OTHER ===
- the DAC start-up sequence should be removed (we have hw-switches for this!)
- modem-legacy uses FLASH memory rather than EEPROM
* https://stackoverflow.com/questions/28503808/allocating-memory-in-flash-for-user-data-stm32f4-hal
* swap to sector 0 (16kb at 0x0800000 - 0x8003FFF)?
-> requires to change linker script and program start address!
- i2c is shared, so we must make sure that the call
eventually succeeds or a fail is handled correctly
in the upper layers
- useage of filterraw command is not in sync with rxgain!
only use filterraw for testing/debugging
ACI - ahoi configuration interface
interface:
- command (CMD) and responses (RSP)
- truth table
CMD | RSP | logic
T T setter: CMD produces response
T F setter: CMD is echoed (with effective values)
F T getter: empty CMD with response
F F not supported*
* = how about RESET and BOOTLOADER?
types for CMD and RSP are always equal (and go by the name ACI_TYPE_xxx), where xxx is the name of the command
Questions:
- what happens in case of an unknown CMD (return something)
- use 0 address as serial host? (this would likely clarify a bunch of things)
Not implemented yet:
- xxxstat_reset
- allstat (should be done by modem.py/client)
FIXME
- switch() case workaround in aci.c
- freqsetup
#!/usr/bin/python3
import re
import os
##
## SETUP
##
INFILE_TYPES = "acitypes.lst"
OUTFILE_TYPES = "acitypes.h"
#OUTFILE_HDR = "aci.h"
OUTFILE_SRC = "aci.c"
# place holder for command type declaration in OUTFILE_TYPES (from INFILE_TYPES)
TPL_TYPES = "[[[ACI_CMD_TYPES]]]"
# place holder for callback initialization in OUTFILE_SRC (from INFILE_TYPES)
TPL_CMD_CB = "[[[ACI_INIT_CMD_CALLBACKS]]]"
TPL_RSP_CB = "[[[ACI_INIT_RSP_CALLBACKS]]]"
# place holder for C-source inclusion in OUTFILE_SRC(from INFILE_TYPES)
TPL_CSRC = "[[[ACI_INC_CSRC]]]"
# patterns
PAT_CSRC = "csrc/aci_%s.c" # C-source file
PAT_CHDR = "csrc/aci_%s.h" # C-header file
PAT_TYPE_CMD = "types/%s_cmd.h" # command type file name
PAT_TYPE_RSP = "types/%s_rsp.h" # response type file name
PAT_TYPE = "ACI_TYPE_%s" # callback method name
PAT_CMD_CB_INIT = "cmdTbl[%s-PACKET_TYPE_CMD_OFFSET] = aci_%s_processCmd;" # cmd callback setup line
PAT_RSP_CB_INIT = "rspTbl[%s-PACKET_TYPE_CMD_OFFSET] = aci_%s_fillReply;" # rsp callback setup line
PAT_CSRC_INC = "#include \"%s\"" # csrc inclusion
##
## TYPE PARSING
##
class PktType:
def __init__(self, n, t):
self.n = n
self.t = t
LST = []
fh = open(INFILE_TYPES, 'r')
l = fh.readline()
while l:
# strip comments
try:
x = l.index("//")
l = l[0:x]
except:
pass
# strip newline
l = l.strip("\n")
# split
t = l.split('=')
if len(t) == 2:
for i in range(0,2):
pat = re.compile(r'\s+')
t[i] = re.sub(pat, '', t[i])
LST.append
LST.append(PktType(t[0], t[1]))
# read next line
l = fh.readline()
fh.close()
##
## process
##
lstTypes = ""
lstCmdCbInit = ""
lstRspCbInit = ""
lstCsrc = ""
def checkFile(fn, exp):
print(" * %s file %s: " % (exp, fn), end='')
if os.path.isfile(fn):
print("YES")
return True
else:
print("NO")
return False
#def genOutput(fout):
# fin = fout + ".in"
# TODO check duplicates
for p in LST:
cmd = p.n.lower()
print("\nfound ACI command %s (%s)" % (p.n, p.t))
# TODO issue warning, if not in upper case?
# check if C-src exists
fCsrc = PAT_CSRC % (cmd)
if not checkFile(fCsrc, 'source file'):
print("WARN skipping type")
continue
# check if C-hdr exists
fChdr = PAT_CHDR % (cmd)
if not checkFile(fChdr, 'header file'):
print("WARN skipping type")
continue
# check if command type exists
fCmd = PAT_TYPE_CMD % cmd
hasCmdType = checkFile(fCmd, 'command type definition')
# check if reply type exists
fRsp = PAT_TYPE_RSP % cmd
hasRspType = checkFile(fRsp, 'response type definition')
# include type into list
fullType = PAT_TYPE % (cmd.upper())
lstTypes += fullType + " = " + p.t + ",\n"
lstCmdCbInit += (PAT_CMD_CB_INIT % (fullType, cmd)) + "\n"
lstRspCbInit += (PAT_RSP_CB_INIT % (fullType, cmd)) + "\n"
lstCsrc += (PAT_CSRC_INC % (fCsrc)) + "\n"
# output types file
print("creating " + OUTFILE_TYPES + ":")
fhIn = open(OUTFILE_TYPES + ".in", 'r')
fData = fhIn.read()
fhIn.close()
fData = fData.replace(TPL_TYPES, lstTypes)
fhOut = open(OUTFILE_TYPES, 'w')
fhOut.write(fData)
fhOut.close()
# output header file
#print("creating " + OUTFILE_HDR + ":")
#fhIn = open(OUTFILE_HDR + ".in", 'r')
#fData = fhIn.read()
#fhIn.close()
#fData = fData.replace(TPL_TYPES, lstTypes)
#fhOut = open(OUTFILE_HDR, 'w')
#fhOut.write(fData)
#fhOut.close()
# output C file
print("creating " + OUTFILE_SRC + ":")
fhIn = open(OUTFILE_SRC + ".in", 'r')
fData = fhIn.read()
fhIn.close()
fData = fData.replace(TPL_CMD_CB, lstCmdCbInit)
fData = fData.replace(TPL_RSP_CB, lstRspCbInit)
fData = fData.replace(TPL_CSRC, lstCsrc)
fhOut = open(OUTFILE_SRC, 'w')
fhOut.write(fData)
fhOut.close()
# eof
/**
* Copyright 2016-2019
*
* Bernd-Christian Renner,
* Jan Heitmann, and
* Hamburg University of Technology (TUHH).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <aci.h>
#include <types.h>
// auto-generated inclusion of source files (ugly)
#include "csrc/aci_version.c"
#include "csrc/aci_config.c"
#include "csrc/aci_id.c"
#include "csrc/aci_batvoltage.c"
#include "csrc/aci_bootloader.c"
#include "csrc/aci_reset.c"
#include "csrc/aci_rxthresh.c"
#include "csrc/aci_spreadcode.c"
#include "csrc/aci_filterraw.c"
#include "csrc/aci_synclen.c"
#include "csrc/aci_agc.c"
#include "csrc/aci_rxgain.c"
#include "csrc/aci_txgain.c"
#include "csrc/aci_peakwinlen.c"
#include "csrc/aci_transducer.c"
#include "csrc/aci_fec.c"
#include "csrc/aci_sample.c"
#include "csrc/aci_sniffmode.c"
#include "csrc/aci_rangingdelay.c"
#include "csrc/aci_test_freq.c"
#include "csrc/aci_test_sweep.c"
#include "csrc/aci_test_noise.c"
#include "csrc/aci_powerlevel.c"
#include "csrc/aci_rxlevel.c"
#include "csrc/aci_packetstat.c"
#include "csrc/aci_packetstat_reset.c"
#include "csrc/aci_syncstat.c"
#include "csrc/aci_syncstat_reset.c"
#include "csrc/aci_sfdstat.c"
#include "csrc/aci_sfdstat_reset.c"
static cmd_handler_t
cmdTbl[PACKET_TYPE_CMD_NUM] = { NULL };
static rsp_handler_t
rspTbl[PACKET_TYPE_CMD_NUM] = { NULL };
void
aci_init(void)
{
// register commands (auto-generated)
cmdTbl[ACI_TYPE_VERSION-PACKET_TYPE_CMD_OFFSET] = aci_version_processCmd;
cmdTbl[ACI_TYPE_CONFIG-PACKET_TYPE_CMD_OFFSET] = aci_config_processCmd;
cmdTbl[ACI_TYPE_ID-PACKET_TYPE_CMD_OFFSET] = aci_id_processCmd;
cmdTbl[ACI_TYPE_BATVOLTAGE-PACKET_TYPE_CMD_OFFSET] = aci_batvoltage_processCmd;
cmdTbl[ACI_TYPE_BOOTLOADER-PACKET_TYPE_CMD_OFFSET] = aci_bootloader_processCmd;
cmdTbl[ACI_TYPE_RESET-PACKET_TYPE_CMD_OFFSET] = aci_reset_processCmd;
cmdTbl[ACI_TYPE_RXTHRESH-PACKET_TYPE_CMD_OFFSET] = aci_rxthresh_processCmd;
cmdTbl[ACI_TYPE_SPREADCODE-PACKET_TYPE_CMD_OFFSET] = aci_spreadcode_processCmd;
cmdTbl[ACI_TYPE_FILTERRAW-PACKET_TYPE_CMD_OFFSET] = aci_filterraw_processCmd;
cmdTbl[ACI_TYPE_SYNCLEN-PACKET_TYPE_CMD_OFFSET] = aci_synclen_processCmd;
cmdTbl[ACI_TYPE_AGC-PACKET_TYPE_CMD_OFFSET] = aci_agc_processCmd;
cmdTbl[ACI_TYPE_RXGAIN-PACKET_TYPE_CMD_OFFSET] = aci_rxgain_processCmd;
cmdTbl[ACI_TYPE_TXGAIN-PACKET_TYPE_CMD_OFFSET] = aci_txgain_processCmd;
cmdTbl[ACI_TYPE_PEAKWINLEN-PACKET_TYPE_CMD_OFFSET] = aci_peakwinlen_processCmd;
cmdTbl[ACI_TYPE_TRANSDUCER-PACKET_TYPE_CMD_OFFSET] = aci_transducer_processCmd;
cmdTbl[ACI_TYPE_FEC-PACKET_TYPE_CMD_OFFSET] = aci_fec_processCmd;
cmdTbl[ACI_TYPE_SAMPLE-PACKET_TYPE_CMD_OFFSET] = aci_sample_processCmd;
cmdTbl[ACI_TYPE_SNIFFMODE-PACKET_TYPE_CMD_OFFSET] = aci_sniffmode_processCmd;
cmdTbl[ACI_TYPE_RANGINGDELAY-PACKET_TYPE_CMD_OFFSET] = aci_rangingdelay_processCmd;
cmdTbl[ACI_TYPE_TEST_FREQ-PACKET_TYPE_CMD_OFFSET] = aci_test_freq_processCmd;
cmdTbl[ACI_TYPE_TEST_SWEEP-PACKET_TYPE_CMD_OFFSET] = aci_test_sweep_processCmd;
cmdTbl[ACI_TYPE_TEST_NOISE-PACKET_TYPE_CMD_OFFSET] = aci_test_noise_processCmd;
cmdTbl[ACI_TYPE_POWERLEVEL-PACKET_TYPE_CMD_OFFSET] = aci_powerlevel_processCmd;
cmdTbl[ACI_TYPE_RXLEVEL-PACKET_TYPE_CMD_OFFSET] = aci_rxlevel_processCmd;
cmdTbl[ACI_TYPE_PACKETSTAT-PACKET_TYPE_CMD_OFFSET] = aci_packetstat_processCmd;
cmdTbl[ACI_TYPE_PACKETSTAT_RESET-PACKET_TYPE_CMD_OFFSET] = aci_packetstat_reset_processCmd;
cmdTbl[ACI_TYPE_SYNCSTAT-PACKET_TYPE_CMD_OFFSET] = aci_syncstat_processCmd;
cmdTbl[ACI_TYPE_SYNCSTAT_RESET-PACKET_TYPE_CMD_OFFSET] = aci_syncstat_reset_processCmd;
cmdTbl[ACI_TYPE_SFDSTAT-PACKET_TYPE_CMD_OFFSET] = aci_sfdstat_processCmd;
cmdTbl[ACI_TYPE_SFDSTAT_RESET-PACKET_TYPE_CMD_OFFSET] = aci_sfdstat_reset_processCmd;
// register commands (auto-generated)
rspTbl[ACI_TYPE_VERSION-PACKET_TYPE_CMD_OFFSET] = aci_version_fillReply;
rspTbl[ACI_TYPE_CONFIG-PACKET_TYPE_CMD_OFFSET] = aci_config_fillReply;
rspTbl[ACI_TYPE_ID-PACKET_TYPE_CMD_OFFSET] = aci_id_fillReply;
rspTbl[ACI_TYPE_BATVOLTAGE-PACKET_TYPE_CMD_OFFSET] = aci_batvoltage_fillReply;
rspTbl[ACI_TYPE_BOOTLOADER-PACKET_TYPE_CMD_OFFSET] = aci_bootloader_fillReply;
rspTbl[ACI_TYPE_RESET-PACKET_TYPE_CMD_OFFSET] = aci_reset_fillReply;
rspTbl[ACI_TYPE_RXTHRESH-PACKET_TYPE_CMD_OFFSET] = aci_rxthresh_fillReply;
rspTbl[ACI_TYPE_SPREADCODE-PACKET_TYPE_CMD_OFFSET] = aci_spreadcode_fillReply;
rspTbl[ACI_TYPE_FILTERRAW-PACKET_TYPE_CMD_OFFSET] = aci_filterraw_fillReply;
rspTbl[ACI_TYPE_SYNCLEN-PACKET_TYPE_CMD_OFFSET] = aci_synclen_fillReply;
rspTbl[ACI_TYPE_AGC-PACKET_TYPE_CMD_OFFSET] = aci_agc_fillReply;
rspTbl[ACI_TYPE_RXGAIN-PACKET_TYPE_CMD_OFFSET] = aci_rxgain_fillReply;
rspTbl[ACI_TYPE_TXGAIN-PACKET_TYPE_CMD_OFFSET] = aci_txgain_fillReply;
rspTbl[ACI_TYPE_PEAKWINLEN-PACKET_TYPE_CMD_OFFSET] = aci_peakwinlen_fillReply;
rspTbl[ACI_TYPE_TRANSDUCER-PACKET_TYPE_CMD_OFFSET] = aci_transducer_fillReply;
rspTbl[ACI_TYPE_FEC-PACKET_TYPE_CMD_OFFSET] = aci_fec_fillReply;
rspTbl[ACI_TYPE_SAMPLE-PACKET_TYPE_CMD_OFFSET] = aci_sample_fillReply;
rspTbl[ACI_TYPE_SNIFFMODE-PACKET_TYPE_CMD_OFFSET] = aci_sniffmode_fillReply;
rspTbl[ACI_TYPE_RANGINGDELAY-PACKET_TYPE_CMD_OFFSET] = aci_rangingdelay_fillReply;
rspTbl[ACI_TYPE_TEST_FREQ-PACKET_TYPE_CMD_OFFSET] = aci_test_freq_fillReply;
rspTbl[ACI_TYPE_TEST_SWEEP-PACKET_TYPE_CMD_OFFSET] = aci_test_sweep_fillReply;
rspTbl[ACI_TYPE_TEST_NOISE-PACKET_TYPE_CMD_OFFSET] = aci_test_noise_fillReply;
rspTbl[ACI_TYPE_POWERLEVEL-PACKET_TYPE_CMD_OFFSET] = aci_powerlevel_fillReply;
rspTbl[ACI_TYPE_RXLEVEL-PACKET_TYPE_CMD_OFFSET] = aci_rxlevel_fillReply;
rspTbl[ACI_TYPE_PACKETSTAT-PACKET_TYPE_CMD_OFFSET] = aci_packetstat_fillReply;
rspTbl[ACI_TYPE_PACKETSTAT_RESET-PACKET_TYPE_CMD_OFFSET] = aci_packetstat_reset_fillReply;
rspTbl[ACI_TYPE_SYNCSTAT-PACKET_TYPE_CMD_OFFSET] = aci_syncstat_fillReply;
rspTbl[ACI_TYPE_SYNCSTAT_RESET-PACKET_TYPE_CMD_OFFSET] = aci_syncstat_reset_fillReply;
rspTbl[ACI_TYPE_SFDSTAT-PACKET_TYPE_CMD_OFFSET] = aci_sfdstat_fillReply;
rspTbl[ACI_TYPE_SFDSTAT_RESET-PACKET_TYPE_CMD_OFFSET] = aci_sfdstat_reset_fillReply;
}
// return true, if packet was a command, false otherwise
bool
//__attribute__ ((noinline))
aci_check(const mm_packet_t * pkt)
{
// HACK
// without any of these two lines, we get a linker/assembler error
// which has probably todo with lto option
// appears to work now ...
// if (pkt->header.type == ACI_TYPE_VERSION) {
// aci_version_processCmd(pkt);
// // send response
// packet_clear(&rsp);
// rsp.header.type = pkt->header.type;
// rsp.header.len = rspTbl[type](rsp.payload);
// aci_sendReply(&rsp);
// return true;
// }
if (pkt->header.type >= PACKET_TYPE_CMD_OFFSET) {
mm_type_t type = pkt->header.type - PACKET_TYPE_CMD_OFFSET;
// TODO assert(type < PACKET_TYPE_CMD_NUM);
if (cmdTbl[type] != NULL) {
mm_packet_t rsp;
// process cmd
cmdTbl[type](pkt);
// send response
packet_clear(&rsp);
rsp.header.type = pkt->header.type;
rsp.header.len = rspTbl[type](rsp.payload);
aci_sendReply(&rsp);
} else {
aci_sendNack(pkt->header.type);
}
return true;
}
return false;
}
void
aci_sendNack(mm_type_t type)
{
// send nack
mm_packet_t nack;
packet_clear(&nack);
nack.header.type = MM_SERIAL_NACK;
nack.header.len = sizeof(uint8_t);
nack.payload[0] = type;
aci_sendReply(&nack);
}
/**
* Copyright 2016-2020
*
* Bernd-Christian Renner,
* Jan Heitmann, and
* Hamburg University of Technology (TUHH).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <aci.h>
#include <types.h>
// auto-generated inclusion of source files (ugly)
[[[ACI_INC_CSRC]]]
static cmd_handler_t
cmdTbl[PACKET_TYPE_CMD_NUM] = { NULL };
static rsp_handler_t
rspTbl[PACKET_TYPE_CMD_NUM] = { NULL };
void
aci_init(void)
{