Skip to content

Commit

Permalink
Merge branch 'feature/emulator_base' of https://github.com/smartanthi…
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankravets committed Mar 16, 2015
2 parents 9c2a6c9 + 7c4d548 commit d095148
Show file tree
Hide file tree
Showing 18 changed files with 2,383 additions and 1,301 deletions.
500 changes: 301 additions & 199 deletions tests/emulator/sa-commlayer.cpp

Large diffs are not rendered by default.

43 changes: 18 additions & 25 deletions tests/emulator/sa-commlayer.h
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
/*******************************************************************************
Copyright (c) 2015, OLogN Technologies AG. All rights reserved.
Redistribution and use of this file in source and compiled
forms, with or without modification, are permitted
provided that the following conditions are met:
* Redistributions in source form must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in compiled 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 OLogN Technologies AG 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 OLogN Technologies AG 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
Copyright (C) 2015 OLogN Technologies AG
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*******************************************************************************/

#if !defined __SA_COMMLAYER_H__
Expand All @@ -31,12 +22,14 @@
// RET codes
#define COMMLAYER_RET_FAILED 0 // not authenticated, etc
#define COMMLAYER_RET_OK 1 // new packet
#define COMMLAYER_RET_PENDING 2


bool communicationInitializeAsServer();
bool communicationInitializeAsClient();
void communicationTerminate();
uint8_t sendMessage( uint16_t* msgSize, const unsigned char * buff );
uint8_t getMessage( uint16_t* msgSize, unsigned char * buff, int maxSize );
uint8_t sendMessage( uint16_t* msgSize, const uint8_t * buff );
uint8_t getMessage( uint16_t* msgSize, uint8_t * buff, int maxSize ); // returns when a packet received
uint8_t tryGetMessage(uint16_t* msgSize, uint8_t * buff, int maxSize); // returns immediately, but a packet reception is not guaranteed

#endif // __SA_COMMLAYER_H__
42 changes: 18 additions & 24 deletions tests/emulator/sa-common.h
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
/*******************************************************************************
Copyright (c) 2015, OLogN Technologies AG. All rights reserved.
Redistribution and use of this file in source and compiled
forms, with or without modification, are permitted
provided that the following conditions are met:
* Redistributions in source form must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in compiled 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 OLogN Technologies AG 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 OLogN Technologies AG 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
Copyright (C) 2015 OLogN Technologies AG
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*******************************************************************************/


Expand All @@ -48,10 +39,13 @@
// note: internal structure is defined by a correspondent handler (see respective .h files for details)
// TODO: think about more reliable mechanism
#define DADA_OFFSET_SASP 0
#define DADA_OFFSET_SAGDP 28
#define DADA_OFFSET_SAGDP ( DADA_OFFSET_SASP + 28 )
#define DADA_OFFSET_NEXT ( DADA_OFFSET_SAGDP + 28 )

// debug helpers

#define DEBUG_PRINTING

#ifdef DEBUG_PRINTING
#include <stdio.h>
#define PRINTF printf
Expand Down
39 changes: 15 additions & 24 deletions tests/emulator/sa-eeprom.cpp
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
/*******************************************************************************
Copyright (c) 2015, OLogN Technologies AG. All rights reserved.
Redistribution and use of this file in source and compiled
forms, with or without modification, are permitted
provided that the following conditions are met:
* Redistributions in source form must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in compiled 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 OLogN Technologies AG 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 OLogN Technologies AG 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
Copyright (C) 2015 OLogN Technologies AG
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*******************************************************************************/

#include "sa-common.h"
Expand All @@ -32,7 +23,7 @@
// Interface is implemented based on file IO
// Files have standard names, each corresponding to master/slave distinguisher and data ID

void prepareFileName( char* nameBuff, unsigned char id )
void prepareFileName( char* nameBuff, uint8_t id )
{
sprintf( nameBuff, "eeprom-%s-%d.dat", MASTER_SLAVE_BIT ? "master" : "slave", id );
}
Expand Down
37 changes: 14 additions & 23 deletions tests/emulator/sa-eeprom.h
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
/*******************************************************************************
Copyright (c) 2015, OLogN Technologies AG. All rights reserved.
Redistribution and use of this file in source and compiled
forms, with or without modification, are permitted
provided that the following conditions are met:
* Redistributions in source form must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in compiled 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 OLogN Technologies AG 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 OLogN Technologies AG 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
Copyright (C) 2015 OLogN Technologies AG
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*******************************************************************************/

#if !defined __SA_EEPROM_H__
Expand Down
43 changes: 18 additions & 25 deletions tests/emulator/sa-timer.cpp
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
/*******************************************************************************
Copyright (c) 2015, OLogN Technologies AG. All rights reserved.
Redistribution and use of this file in source and compiled
forms, with or without modification, are permitted
provided that the following conditions are met:
* Redistributions in source form must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in compiled 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 OLogN Technologies AG 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 OLogN Technologies AG 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
Copyright (C) 2015 OLogN Technologies AG
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*******************************************************************************/

#include "sa-timer.h"
Expand All @@ -31,14 +22,16 @@

#include <Windows.h>

#define TIME_FACTOR 500

void waitForTimeQuantum()
{
Sleep(1);
Sleep(TIME_FACTOR);
}

unsigned short getTime()
{
return (unsigned short)( GetTickCount() );
return (unsigned short)( GetTickCount() / TIME_FACTOR ); // 100 ms
}

#endif
37 changes: 14 additions & 23 deletions tests/emulator/sa-timer.h
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
/*******************************************************************************
Copyright (c) 2015, OLogN Technologies AG. All rights reserved.
Redistribution and use of this file in source and compiled
forms, with or without modification, are permitted
provided that the following conditions are met:
* Redistributions in source form must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in compiled 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 OLogN Technologies AG 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 OLogN Technologies AG 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
Copyright (C) 2015 OLogN Technologies AG
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*******************************************************************************/

#if !defined __SA_TIMER_H__
Expand Down
Loading

0 comments on commit d095148

Please sign in to comment.