Skip to content

Commit 670b84d

Browse files
mszeuMarco Simone Zuppone
andauthored
Devel (#24)
* Changes in decoding the command NO due to FW 1.9a * Version change and minor fixes * Minor comments fixes --------- Co-authored-by: Marco Simone Zuppone <m.zuppone@computer.org>
1 parent 2d9c243 commit 670b84d

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# PayShieldPressureTest
22

3-
<img src=images/supporting-member-badge.png width=100>
3+
<img src=images/supporting-member-badge.png width=100 alt="logo of Python Foundation Supporting Member">
44

55
The **pressureTest.py** Python script creates a workload on the **Thales payShield 10k** and **9k** appliances.
66
The script can be useful during demonstrations of the monitoring features of the appliance and can be used in every case
77
you need to generate a workload for testing purposes.
88

9-
It requires **Python 3**. It was tested on **Python 3.10.2** using a **payShield 10k** with firmware **1.7**.
9+
It requires **Python 3**. It was tested on **Python 3.10.2** using a **payShield 10k** with firmware **1.7a**.
1010

1111
## Version
1212

13-
**1.3**
13+
**1.3.1**
1414

1515
## Usage
1616

@@ -103,7 +103,7 @@ The possible choices are:
103103

104104
C:\Test>python pressureTest.py 192.168.0.36 --nc --times 2
105105

106-
PayShield stress utility, version 1.3, by Marco S. Zuppone - msz@msz.eu - https://msz.eu
106+
PayShield stress utility, version 1.3.1, by Marco S. Zuppone - msz@msz.eu - https://msz.eu
107107
To get more info about the usage invoke it with the -h option This software is open source, and it is under the Affero
108108
AGPL 3.0 license
109109

pressureTest.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from typing import Tuple, Dict
1515
from types import FunctionType
1616

17-
VERSION = "1.3"
17+
VERSION = "1.3.1"
1818

1919

2020
class PayConnector:
@@ -233,13 +233,18 @@ def decode_no(response_to_decode: bytes, head_len: int):
233233
str_pointer = str_pointer + 1
234234
print("Type of connection: ", NET_PROTO.get(response_to_decode[str_pointer:str_pointer + 1], "Unknown"))
235235
str_pointer = str_pointer + 1
236-
print("Number of TCP sockets: ", response_to_decode[str_pointer:str_pointer + 2])
237-
str_pointer = str_pointer + 2
236+
if len(response_to_decode) > (24 + head_len): # FW 1.8a or more
237+
socket_field_len = 4 # From FW 1.8a the Number of TCP sockets is 4 character long instead of 2
238+
else:
239+
socket_field_len = 2
240+
print("Number of TCP sockets: ", response_to_decode[str_pointer:str_pointer + socket_field_len])
241+
str_pointer = str_pointer + socket_field_len
238242
print("Firmware number: ", response_to_decode[str_pointer:str_pointer + 9])
239243
str_pointer = str_pointer + 9
240244
print("Reserved: ", response_to_decode[str_pointer:str_pointer + 1])
241245
str_pointer = str_pointer + 1
242246
print("Reserved: ", response_to_decode[str_pointer:str_pointer + 4])
247+
243248
else: # Mode 01
244249
str_pointer = str_pointer + 2
245250
if response_to_decode[str_pointer:str_pointer + 1] == '0':
@@ -1003,8 +1008,8 @@ def common_parser(response_to_decode: bytes, head_len: int) -> Tuple[str, int, i
10031008

10041009
parser = argparse.ArgumentParser(
10051010
description="Generates workload on PayShield 10k and 9k for the sake of testing and demonstration.",
1006-
epilog="For any questions, feedback, suggestions or send money (yes...it's a dream, I know), you can contact the "
1007-
"author at msz@msz.eu")
1011+
epilog="For any questions, feedback, suggestions or send money (yes...it's a dream, I know), you can contact "
1012+
"the author at msz@msz.eu")
10081013
parser.add_argument("host", help="Ip address or hostname of the payShield")
10091014
group = parser.add_mutually_exclusive_group()
10101015
parser.add_argument("--port", "-p", help="The host port. "
@@ -1050,7 +1055,6 @@ def common_parser(response_to_decode: bytes, head_len: int) -> Tuple[str, int, i
10501055
parser.add_argument("--decode", help="If specified the reply of the payShield is interpreted "
10511056
"if a decoder function for that command has been implemented.",
10521057
action="store_true")
1053-
10541058
parser.add_argument("--times", help="How many times to repeat the operation "
10551059
"If not specified the default is 1000.", type=int, default=1000)
10561060
parser.add_argument("--proto", help="Accepted values are tcp, udp or tls. The default is tcp", default="tcp",

0 commit comments

Comments
 (0)