Skip to content

Commit

Permalink
main.h added to src folder
Browse files Browse the repository at this point in the history
  • Loading branch information
RainerZ committed Feb 13, 2024
1 parent 8f11eda commit c62d712
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 10 deletions.
4 changes: 3 additions & 1 deletion CPP_Demo/CPP_Demo.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="main.h" />
<ClInclude Include="main_cfg.h" />
<ClInclude Include="xcptl_cfg.h" />
<ClInclude Include="xcp_cfg.h" />
Expand Down Expand Up @@ -71,6 +70,9 @@
<ClInclude Include="..\src\options.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="main.h">
<Filter>src</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="src">
Expand Down
4 changes: 3 additions & 1 deletion C_Demo/C_Demo.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="ecu.h" />
<ClInclude Include="main.h" />
<ClInclude Include="main_cfg.h" />
<ClInclude Include="xcptl_cfg.h" />
<ClInclude Include="..\src\A2L.h">
Expand Down Expand Up @@ -61,6 +60,9 @@
<ClInclude Include="..\src\dbg_print.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="main.h">
<Filter>src</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="src">
Expand Down
2 changes: 1 addition & 1 deletion XCPlite/XCPlite.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@
<ItemGroup>
<ClInclude Include="..\src\A2L.h" />
<ClInclude Include="..\src\dbg_print.h" />
<ClInclude Include="..\src\main.h" />
<ClInclude Include="..\src\platform.h" />
<ClInclude Include="..\src\xcp.h" />
<ClInclude Include="..\src\xcpEthServer.h" />
<ClInclude Include="..\src\xcpEthTl.h" />
<ClInclude Include="..\src\xcpLite.h" />
<ClInclude Include="..\src\xcpTl.h" />
<ClInclude Include="main.h" />
<ClInclude Include="main_cfg.h" />
<ClInclude Include="xcpTl_cfg.h" />
<ClInclude Include="xcp_cfg.h" />
Expand Down
4 changes: 3 additions & 1 deletion XCPlite/XCPlite.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
<ClInclude Include="..\src\xcpLite.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="main.h" />
<ClInclude Include="main_cfg.h" />
<ClInclude Include="xcpTl_cfg.h" />
<ClInclude Include="..\src\xcpEthTl.h">
Expand All @@ -50,6 +49,9 @@
<ClInclude Include="..\src\xcpEthServer.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\src\main.h">
<Filter>src</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="src">
Expand Down
19 changes: 17 additions & 2 deletions src/A2L.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ static uint32_t gA2lComponents;
static uint32_t gA2lInstances;
static uint32_t gA2lConversions;


//----------------------------------------------------------------------------------
// Check for memory accessibility
//#define A2L_ENABLE_MEMORY_CHECK
#ifdef A2L_ENABLE_MEMORY_CHECK
static void mem_check(const char* name, int32_t type, uint8_t ext, uint32_t addr) {
(void)type; (void)name;
volatile uint8_t *p = ApplXcpGetPointer(ext,addr);
if (p==NULL) { DBG_PRINTF1("ERROR: memory address 0x%04X of variable %s not accessible !\n",addr,name); assert(0); }
volatile uint8_t b = *p; // if this leads to a memory protection error, check if address transformation from A2L to uint_8_p* transformation is correct
}
#endif


//----------------------------------------------------------------------------------
static const char* gA2lHeader =
"ASAP2_VERSION 1 71\n"
Expand Down Expand Up @@ -201,7 +215,6 @@ static const char* const gA2lFooter =
#define printAddrExt(ext) if (ext>0) fprintf(gA2lFile, " ECU_ADDRESS_EXTENSION %u",ext);

const char* A2lGetSymbolName(const char* instanceName, const char* name) {

static char s[256];
if (instanceName != NULL && strlen(instanceName) > 0) {
SNPRINTF(s, 256, "%s.%s", instanceName, name);
Expand Down Expand Up @@ -287,7 +300,6 @@ static const char* getPhysMax(int32_t type, double factor, double offset) {
case A2L_TYPE_UINT32: value = 4294967295; break;
default: value = 1E12;
}

static char str[20];
snprintf(str, 20, "%f", factor * value + offset);
return str;
Expand Down Expand Up @@ -526,6 +538,9 @@ void A2lCreateTypedefInstance_(const char* instanceName, const char* typeName, u
void A2lCreateMeasurement_(const char* instanceName, const char* name, int32_t type, uint8_t ext, uint32_t addr, double factor, double offset, const char* unit, const char* comment) {

assert(gA2lFile != NULL);
#ifdef A2L_ENABLE_MEMORY_CHECK
mem_check(name, type, ext, addr);
#endif
if (unit == NULL) unit = "";
if (comment == NULL) comment = "";
const char *conv = "NO";
Expand Down
5 changes: 3 additions & 2 deletions src/A2L.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
/* Copyright(c) Vector Informatik GmbH.All rights reserved.
Licensed under the MIT license.See LICENSE file in the project root for details. */

#define OPTION_ENABLE_A2L_SYMBOL_LINKS ON // Enable generation of symbol links (required for CANape integrated linker map update)


#define A2L_TYPE_UINT8 1
#define A2L_TYPE_UINT16 2
#define A2L_TYPE_UINT32 4
Expand All @@ -21,8 +24,6 @@
#define A2lGetAddr(p) ApplXcpGetAddr(p)
#endif

#define OPTION_ENABLE_A2L_SYMBOL_LINKS ON // Enable generation of symbol links (required for CANape integrated linker map update)

#ifdef __cplusplus

#include <typeinfo>
Expand Down
10 changes: 9 additions & 1 deletion CPP_Demo/main.h → src/main.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once

/* main.h */
/*
| Code released into public domain, no attribution required
Expand Down Expand Up @@ -77,11 +78,18 @@
#include <time.h>
#include <conio.h>

#define BOOL int
#define FALSE 0
#define TRUE 1

#endif

#ifdef __cplusplus
#include <typeinfo>
#include <thread>
#include <string>
#include <vector>
#endif

#include "main_cfg.h"

#include "main_cfg.h"
2 changes: 1 addition & 1 deletion src/xcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ std::vector<Xcp::XcpEventDescriptor>* Xcp::getEventList() {
uint64_t ns = evtList[i].timeCycle;
uint8_t exp = evtList[i].timeUnit;
while (exp-- > 0) ns *= 10;
l->push_back(Xcp::XcpEventDescriptor(evtList[i].name, (uint32_t)(ns / 1000), evtList[i].priority, evtList[i].sampleCount, evtList[i].size));
l->push_back(Xcp::XcpEventDescriptor(evtList[i].shortName, (uint32_t)(ns / 1000), evtList[i].priority, evtList[i].sampleCount, evtList[i].size));
}
return l;
}
Expand Down

0 comments on commit c62d712

Please sign in to comment.