Skip to content

Commit f265d27

Browse files
committed
deps: snap7 1.4.0
Missed some files in the recent version bump :/
1 parent 6e18c89 commit f265d27

5 files changed

Lines changed: 98 additions & 170 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![NPM](https://nodei.co/npm/node-snap7.png?downloads=true)](https://nodei.co/npm/node-snap7/) [![NPM](https://nodei.co/npm-dl/node-snap7.png?months=1)](https://nodei.co/npm/node-snap7/)
44

5-
**Current node-snap7 version:** 0.2.0
5+
**Current node-snap7 version:** 0.2.1
66
**Current snap7 version:** 1.4.0
77

88
**Build status:** Linux [![Build Status](https://travis-ci.org/mathiask88/node-snap7.svg?branch=master)](https://travis-ci.org/mathiask88/node-snap7) Windows [![Build status](https://ci.appveyor.com/api/projects/status/ca1kepectsn3wkrc)](https://ci.appveyor.com/project/mathiask88/node-snap7)

deps/snap7/HISTORY.txt

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,77 @@
1+
======================================================================[2015-06-14]
2+
Version 1.4.0 - release for gourmets (fully compatible with 1.0.0)
3+
----------------------------------------------------------------------------------
4+
5+
- Resourceless Server
6+
- Utility added
7+
- Improved .NET wrapper
8+
- New .NET Demos
9+
- Solution also for .NET Console demos
10+
- Small bugfix
11+
12+
[Added]
13+
14+
- Resourceless server
15+
Now Snap7Server can work in "resourceless" mode, i.e. you don�t need to share
16+
resources (DB, E, A�) with it : On every read/write request a callback is
17+
called passing it the TAG (Type of memory E,A,DB..,DB number if any, Start,
18+
Size, WordLen), and a pointer to the internal server area to read/write your
19+
data �on demand�.
20+
21+
The 1.4.0 wrappers were updated to reflect this new mode and I wrote some
22+
examples on how to use this feature, that however is very simple.
23+
Purpose:
24+
- Protocol converters.
25+
- HMI Analyzers.
26+
- Flow Splitters/Routers.
27+
28+
- Utility
29+
There is a new folder that contains some interesting (I hope) utilities.
30+
They are demo programs with a "real purpose".
31+
The first is HMITracer, a program that shows how use the new resourceless
32+
server. It simulates a PLC and lists all Tags referenced by an external HMI.
33+
A detailed PDF report is generated also.
34+
35+
[Improved]
36+
37+
- Improved .NET wrapper
38+
Now the S7 Helper class can convert *ALL* S7 types, including the new
39+
S71200/1500 64 bit types :
40+
- 8, 16, 32, 64 bit signed and unsigned values.
41+
- Long real (64 bit)
42+
- Long Date/Time, Long Time of Day
43+
44+
- Added the class S7MultiVars which greatly simplifies the reading and writing of
45+
MultiVars.
46+
47+
- New .NET Demos
48+
Added WinForm Server Demo and MultiRead vars Demo.
49+
Added 64 platform for all demos
50+
Added the compilation of Snap7.net.cs for VB demos.
51+
52+
- Solution also for .NET Console demos
53+
A VS2013 solution for .NET console demos was added.
54+
you no longer need the of the batch file to build the demos.
55+
56+
- Reduced the memory footprint of Snap7Server (there was an unused memory block).
57+
58+
[Fixed]
59+
60+
- (Only Windows) If an attacker gains control of the application directory, he
61+
could force the application to load a malicious copy of iphlpapi.dll (which
62+
is used for ping).
63+
Now iphlpapi.dll is loaded from the Windows system directory.
64+
Thanks to the Security engineer Alexandre CHERON for reporting it.
65+
66+
167
======================================================================[2015-01-01]
268
Version 1.3.0 - Platform / Comfort release (fully compatible with 1.0.0)
369
----------------------------------------------------------------------------------
470

571
Platform
672
- Runtime Big-Endian architecture support. No compilers swithes are needed.
773
- Sun Sparc and Mips BE architectures are now supported.
74+
- Arduino YUN
875

976
Comfort
1077
- Added WinForm.net demos (C# and VB)
@@ -20,6 +87,8 @@ Comfort
2087
You will find them into the wrappers (.net/Pascal/C++)
2188
- Solaris Sparc support
2289
(Thanks to Rolf Stalder for makefiles)
90+
- Arduino YUN support
91+
(Thanks to Fulvio Bosco and Stefano Bonnin)
2392
- .Net Winform small demos
2493
- .Net solution for rebuilding snap7.net.cs
2594

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "node-snap7",
33
"main": "./lib/node-snap7.js",
4-
"version": "0.2.0",
4+
"version": "0.2.1",
55
"description": "Native node.js addon/wrapper for snap7",
66
"homepage": "https://github.com/mathiask88/node-snap7",
77
"repository": {

src/snap7.cpp

Lines changed: 7 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*=============================================================================|
2-
| PROJECT SNAP7 1.3.0 |
2+
| PROJECT SNAP7 1.4.0 |
33
|==============================================================================|
44
| Copyright (C) 2013, 2014 Davide Nardella |
55
| All rights reserved. |
@@ -524,7 +524,12 @@ int TS7Server::SetEventsCallback(pfn_SrvCallBack PCallBack, void *UsrPtr)
524524
//---------------------------------------------------------------------------
525525
int TS7Server::SetReadEventsCallback(pfn_SrvCallBack PCallBack, void *UsrPtr)
526526
{
527-
return Srv_SetReadEventsCallback(Server, PCallBack, UsrPtr);
527+
return Srv_SetReadEventsCallback(Server, PCallBack, UsrPtr);
528+
}
529+
//---------------------------------------------------------------------------
530+
int TS7Server::SetRWAreaCallback(pfn_RWAreaCallBack PCallBack, void *UsrPtr)
531+
{
532+
return Srv_SetRWAreaCallback(Server, PCallBack, UsrPtr);
528533
}
529534
//---------------------------------------------------------------------------
530535
bool TS7Server::PickEvent(TSrvEvent *pEvent)
@@ -767,138 +772,4 @@ TextString SrvEventText(TSrvEvent *Event)
767772
Srv_EventText(Event, text, TextLen);
768773
return TextString(text);
769774
}
770-
//==============================================================================
771-
// Helper GET routines
772-
//==============================================================================
773-
word SwapWord(pword Value)
774-
{
775-
return ((*Value >> 8) & 0xFF) | ((*Value << 8) & 0xFF00);
776-
}
777-
//---------------------------------------------------------------------------
778-
longword SwapDWord(plongword Value)
779-
{
780-
return (*Value >> 24) | ((*Value << 8) & 0x00FF0000) | ((*Value >> 8) & 0x0000FF00) | (*Value << 24);
781-
}
782-
//---------------------------------------------------------------------------
783-
bool GetBitAt(void *Buffer, int Pos, int Bit)
784-
{
785-
byte Mask[] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
786-
if (Bit < 0) Bit = 0;
787-
if (Bit > 7) Bit = 7;
788-
return (*(pbyte(Buffer)+Pos) & Mask[Bit]) != 0;
789-
}
790-
//---------------------------------------------------------------------------
791-
byte GetByteAt(void *Buffer, int Pos)
792-
{
793-
return *(pbyte(Buffer)+Pos);
794-
}
795-
//---------------------------------------------------------------------------
796-
word GetWordAt(void *Buffer, int Pos)
797-
{
798-
return SwapWord(pword(pbyte(Buffer)+Pos));
799-
}
800-
//---------------------------------------------------------------------------
801-
smallint GetIntAt(void *Buffer, int Pos)
802-
{
803-
return smallint(SwapWord(pword(pbyte(Buffer)+Pos)));
804-
}
805-
//---------------------------------------------------------------------------
806-
longword GetDWordAt(void *Buffer, int Pos)
807-
{
808-
return SwapDWord(plongword(pbyte(Buffer)+Pos));
809-
}
810-
//---------------------------------------------------------------------------
811-
longint GetDIntAt(void *Buffer, int Pos)
812-
{
813-
return longint(SwapDWord(plongword(pbyte(Buffer)+Pos)));
814-
}
815-
//---------------------------------------------------------------------------
816-
float GetRealAt(void *Buffer, int Pos)
817-
{
818-
longword lw=SwapDWord(plongword(pbyte(Buffer)+Pos));
819-
return *pfloat(&lw);
820-
}
821-
//---------------------------------------------------------------------------
822-
byte BCDtoByte(byte B)
823-
{
824-
return ((B >> 4) * 10) + (B & 0x0F);
825-
}
826-
//---------------------------------------------------------------------------
827-
struct tm GetDateTimeAt(void *Buffer, int Pos)
828-
{
829-
struct tm DateTime;
830-
pbyte p = pbyte(Buffer)+Pos;
831-
word Year=BCDtoByte(*p);
832775

833-
if (Year<90) Year+=100;
834-
DateTime.tm_year=Year;
835-
DateTime.tm_mon =BCDtoByte(*(p+1))-1;
836-
DateTime.tm_mday=BCDtoByte(*(p+2));
837-
DateTime.tm_hour=BCDtoByte(*(p+3));
838-
DateTime.tm_min =BCDtoByte(*(p+4));
839-
DateTime.tm_sec =BCDtoByte(*(p+5));
840-
DateTime.tm_wday=(*(p+7) & 0x0F)-1;
841-
return DateTime;
842-
}
843-
//==============================================================================
844-
// Helper SET routines
845-
//==============================================================================
846-
void SetBitAt(void *Buffer, int Pos, int Bit, bool Value)
847-
{
848-
byte Mask[] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
849-
pbyte p = pbyte(Buffer)+Pos;
850-
if (Bit < 0) Bit = 0;
851-
if (Bit > 7) Bit = 7;
852-
(Value) ? *p |= Mask[Bit] : *p &= ~Mask[Bit];
853-
}
854-
//---------------------------------------------------------------------------
855-
void SetByteAt(void *Buffer, int Pos, byte Value)
856-
{
857-
*(pbyte(Buffer)+Pos)=Value;
858-
}
859-
//---------------------------------------------------------------------------
860-
void SetWordAt(void *Buffer, int Pos, word Value)
861-
{
862-
*(pword(pbyte(Buffer)+Pos))=SwapWord(&Value);
863-
}
864-
//---------------------------------------------------------------------------
865-
void SetIntAt(void *Buffer, int Pos, smallint Value)
866-
{
867-
*(psmallint(pbyte(Buffer)+Pos))=SwapWord(pword(&Value));
868-
}
869-
//---------------------------------------------------------------------------
870-
void SetDWordAt(void *Buffer, int Pos, longword Value)
871-
{
872-
*(plongword(pbyte(Buffer)+Pos))=SwapDWord(&Value);
873-
}
874-
//---------------------------------------------------------------------------
875-
void SetDIntAt(void *Buffer, int Pos, longint Value)
876-
{
877-
*(plongint(pbyte(Buffer)+Pos))=SwapDWord(plongword(&Value));
878-
}
879-
//---------------------------------------------------------------------------
880-
void SetRealAt(void *Buffer, int Pos, float Value)
881-
{
882-
*(plongword(pbyte(Buffer)+Pos))=SwapDWord(plongword(&Value));
883-
}
884-
//---------------------------------------------------------------------------
885-
byte WordToBCD(word Value)
886-
{
887-
return ((Value / 10) << 4) | (Value % 10);
888-
}
889-
//---------------------------------------------------------------------------
890-
void SetDateTimeAt(void *Buffer, int Pos, tm Value)
891-
{
892-
pbyte p = pbyte(Buffer)+Pos;
893-
word Year = Value.tm_year;
894-
895-
if (Year>99) Year-=100;
896-
*p=WordToBCD(Year);
897-
*(p+1)=WordToBCD(Value.tm_mon+1);
898-
*(p+2)=WordToBCD(Value.tm_mday);
899-
*(p+3)=WordToBCD(Value.tm_hour);
900-
*(p+4)=WordToBCD(Value.tm_min);
901-
*(p+5)=WordToBCD(Value.tm_sec);
902-
*(p+6)=0;
903-
*(p+7)=Value.tm_wday+1;
904-
}

src/snap7.h

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*=============================================================================|
2-
| PROJECT SNAP7 1.3.0 |
2+
| PROJECT SNAP7 1.4.0 |
33
|==============================================================================|
44
| Copyright (C) 2013, 2014 Davide Nardella |
55
| All rights reserved. |
@@ -143,15 +143,9 @@ extern "C" {
143143
// Exact length types regardless of platform/processor
144144
typedef uint8_t byte;
145145
typedef uint16_t word;
146-
typedef int16_t smallint;
147146
typedef uint32_t longword;
148-
typedef int32_t longint;
149147
typedef byte *pbyte;
150148
typedef word *pword;
151-
typedef longword *plongword;
152-
typedef smallint *psmallint;
153-
typedef longint *plongint;
154-
typedef float *pfloat;
155149
typedef uintptr_t S7Object; // multi platform/processor object reference
156150
// DON'T CONFUSE IT WITH AN OLE OBJECT, IT'S SIMPLY
157151
// AN INTEGER VALUE (32 OR 64 BIT) USED AS HANDLE.
@@ -200,6 +194,15 @@ const longword errIsoResvd_2 = 0x000D0000; // Unassigned
200194
const longword errIsoResvd_3 = 0x000E0000; // Unassigned
201195
const longword errIsoResvd_4 = 0x000F0000; // Unassigned
202196

197+
// Tag Struct
198+
typedef struct{
199+
int Area;
200+
int DBNumber;
201+
int Start;
202+
int Size;
203+
int WordLen;
204+
}TS7Tag, *PS7Tag;
205+
203206
//------------------------------------------------------------------------------
204207
// PARAMS LIST
205208
//------------------------------------------------------------------------------
@@ -525,6 +528,8 @@ int S7API Cli_WaitAsCompletion(S7Object Client, int Timeout);
525528
//******************************************************************************
526529
// SERVER
527530
//******************************************************************************
531+
const int OperationRead = 0;
532+
const int OperationWrite = 1;
528533

529534
const int mkEvent = 0;
530535
const int mkLog = 1;
@@ -644,8 +649,11 @@ typedef struct{
644649
word EvtParam4; // Param 4 (if available)
645650
}TSrvEvent, *PSrvEvent;
646651

647-
// Server Evants callback
648-
typedef void (S7API *pfn_SrvCallBack)(void * usrPtr, PSrvEvent PEvent, int Size);
652+
// Server Events callback
653+
typedef void (S7API *pfn_SrvCallBack)(void *usrPtr, PSrvEvent PEvent, int Size);
654+
// Server Read/Write callback
655+
typedef int(S7API *pfn_RWAreaCallBack)(void *usrPtr, int Sender, int Operation, PS7Tag PTag, void *pUsrData);
656+
649657
S7Object S7API Srv_Create();
650658
void S7API Srv_Destroy(S7Object *Server);
651659
int S7API Srv_GetParam(S7Object Server, int ParamNumber, void *pValue);
@@ -665,6 +673,7 @@ int S7API Srv_GetMask(S7Object Server, int MaskKind, longword *Mask);
665673
int S7API Srv_SetMask(S7Object Server, int MaskKind, longword Mask);
666674
int S7API Srv_SetEventsCallback(S7Object Server, pfn_SrvCallBack pCallback, void *usrPtr);
667675
int S7API Srv_SetReadEventsCallback(S7Object Server, pfn_SrvCallBack pCallback, void *usrPtr);
676+
int S7API Srv_SetRWAreaCallback(S7Object Server, pfn_RWAreaCallBack pCallback, void *usrPtr);
668677
int S7API Srv_EventText(TSrvEvent *Event, char *Text, int TextLen);
669678
int S7API Srv_ErrorText(int Error, char *Text, int TextLen);
670679

@@ -734,28 +743,6 @@ int S7API Par_GetLastError(S7Object Partner, int *LastError);
734743
int S7API Par_GetStatus(S7Object Partner, int *Status);
735744
int S7API Par_ErrorText(int Error, char *Text, int TextLen);
736745

737-
//******************************************************************************
738-
// HELPER DATA ACCESS FUNCTIONS
739-
//******************************************************************************
740-
// GET
741-
bool GetBitAt(void *Buffer, int Pos, int Bit);
742-
byte GetByteAt(void *Buffer, int Pos);
743-
word GetWordAt(void *Buffer, int Pos);
744-
smallint GetIntAt(void *Buffer, int Pos);
745-
longword GetDWordAt(void *Buffer, int Pos);
746-
longint GetDIntAt(void *Buffer, int Pos);
747-
float GetRealAt(void *Buffer, int Pos);
748-
struct tm GetDateTimeAt(void *Buffer, int Pos);
749-
// SET
750-
void SetBitAt(void *Buffer, int Pos, int Bit, bool Value);
751-
void SetByteAt(void *Buffer, int Pos, byte Value);
752-
void SetWordAt(void *Buffer, int Pos, word Value);
753-
void SetIntAt(void *Buffer, int Pos, smallint Value);
754-
void SetDWordAt(void *Buffer, int Pos, longword Value);
755-
void SetDIntAt(void *Buffer, int Pos, longint Value);
756-
void SetRealAt(void *Buffer, int Pos, float Value);
757-
void SetDateTimeAt(void *Buffer, int Pos, tm Value);
758-
759746

760747
#pragma pack()
761748
#ifdef __cplusplus
@@ -887,7 +874,8 @@ class TS7Server
887874
int SetParam(int ParamNumber, void *pValue);
888875
// Events
889876
int SetEventsCallback(pfn_SrvCallBack PCallBack, void *UsrPtr);
890-
int SetReadEventsCallback(pfn_SrvCallBack PCallBack, void *UsrPtr);
877+
int SetReadEventsCallback(pfn_SrvCallBack PCallBack, void *UsrPtr);
878+
int SetRWAreaCallback(pfn_RWAreaCallBack PCallBack, void *UsrPtr);
891879
bool PickEvent(TSrvEvent *pEvent);
892880
void ClearEvents();
893881
longword GetEventsMask();

0 commit comments

Comments
 (0)