Skip to content

Commit b442fd8

Browse files
committed
read single, write single and read multiple working
1 parent 79ab5f6 commit b442fd8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+770
-26
lines changed

README.md

100644100755
File mode changed.

outback_C_interface/AllOutput.txt

100644100755
File mode changed.

outback_C_interface/OBencrypt.h

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* OBencrypt.h version 0.87 Feb. 13, 2012
2+
*
3+
* Written by Daniel Lloyd. 2011-2012.
4+
* Property of OutBack Power Systems Inc.
5+
*/
6+
7+
#ifndef OutBack_OBencrypt_h
8+
#define OutBack_OBencrypt_h
9+
10+
#define BIAS (0x0BCC)
11+
#define ROTATE_R7(x) ((((x) & 0x007F) << 9) | ((x) >> 7))
12+
#define ROTATE_L7(x) ((((x) & 0x01FF) << 7) | ((x) >> 9))
13+
14+
#define ENCRYPT(x) ((x) = (ROTATE_R7((x) ^ BIAS) ^ encKey))
15+
#define DECRYPT(x) ((x) = (ROTATE_L7((x) ^ encKey) ^ BIAS))
16+
17+
#define ENCRYPTION_ENABLED
18+
19+
#endif

outback_C_interface/Outback_p.c

100644100755
+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#define DEF_SERV_IP_ADDR "192.168.2.220"
2626
#define BUFF_SIZE 128
2727

28-
int debug = 0;-
28+
int debug = 0;
2929
int devices = 0;
3030
int connected = 0;
3131
int pflag = 0;
@@ -60,7 +60,7 @@ int string_split(void) {
6060
printf("%s\n", ch);
6161
ch = strtok(NULL, " ,");
6262
}
63-
getch();
63+
//getch();
6464
return 0;
6565
}
6666

outback_C_interface/blocks.txt

100644100755
File mode changed.

outback_C_interface/modbus-data.c

100644100755
File mode changed.

outback_C_interface/modbus-private.h

100644100755
File mode changed.

outback_C_interface/modbus-tcp-private.h

100644100755
File mode changed.

outback_C_interface/modbus-tcp.c

100644100755
File mode changed.

outback_C_interface/modbus-tcp.h

100644100755
File mode changed.

outback_C_interface/modbus-version.h

100644100755
File mode changed.

outback_C_interface/modbus.c

100644100755
File mode changed.

outback_C_interface/modbus.h

100644100755
File mode changed.

outback_C_interface/names.h

100644100755
File mode changed.

outback_C_interface/outback

121 KB
Binary file not shown.

outback_C_interface/outback.c

100644100755
File mode changed.

outback_C_interface/outback.h

100644100755
File mode changed.

outback_C_interface/output.error

100644100755
File mode changed.

outback_C_interface/program

122 KB
Binary file not shown.

outback_C_interface/registers.h

100644100755
+2-2
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ struct alt_multiple_register system_data[] = {
118118
{"OutBack_Measured_System_Voltage",159, OUTBACK_BLOCK},
119119
};
120120

121-
121+
/*
122122
struct alt_multiple_register system_data[] = {
123123
{"OutBack_Error",154, OUTBACK_BLOCK},
124124
{"OutBack_Status",155, OUTBACK_BLOCK},
125125
{"OutBack_System_Voltage",158, OUTBACK_BLOCK},
126126
{"OutBack_Measured_System_Voltage",159, OUTBACK_BLOCK},
127127
};
128-
128+
*/

wrapper_python/InverterFactory.py

100644100755
File mode changed.

wrapper_python/InverterFactory.pyc

1.13 KB
Binary file not shown.

wrapper_python/__init__.py

100644100755
File mode changed.

wrapper_python/hardware_dispatch.py

100644100755
File mode changed.

wrapper_python/inverter.json

100644100755
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"ip": "169.254.64.7", "type": "outback"}
1+
{"ip": "169.254.7.64", "type": "outback"}
Binary file not shown.

wrapper_python/outback/AllOutputUpdated.txt

+687
Large diffs are not rendered by default.

wrapper_python/outback/OutbackInverterClass.py

100644100755
+18-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,23 @@ def read(self, name):
7676
else:
7777
logger.error("Invalid Register {}".format(name))
7878

79+
def read_multiple(self, reg_names):
80+
"""
81+
Read multiple register of Outback
82+
:param name:
83+
:return:
84+
"""
85+
fields = []
86+
blocks = []
87+
for name in reg_names:
88+
reg = self.get_register(name)
89+
if reg is not None:
90+
fields.append(reg.field)
91+
blocks.append(reg.block)
92+
else:
93+
logger.error(name + " not present")
94+
return register.read_multiple_reg(self.ip, fields, blocks)
95+
7996
def read_single(self, field, block):
8097
"""
8198
Read register of Outback
@@ -421,4 +438,4 @@ def write_single_reg(self, dict_fields):
421438
logger.error("invalid register fields")
422439
return -1
423440

424-
return self.write_single(field, block, value)
441+
return self.write_single(field, block, value)
18.6 KB
Binary file not shown.

wrapper_python/outback/__init__.py

100644100755
File mode changed.

wrapper_python/outback/__init__.pyc

210 Bytes
Binary file not shown.

wrapper_python/outback/__utils__.py

100644100755
File mode changed.

wrapper_python/outback/__utils__.pyc

404 Bytes
Binary file not shown.

wrapper_python/outback/block_conf.py

100644100755
+4-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
PACKET_STATISTICS_BLOCK = 4
1111
RADIAN_SINGLE_PHASE_INV = 5
1212
RADIAN_INV_CONF_BLOCK = 6
13-
BATTERY_MONITOR_BLOCK = 7
14-
BATTERY_MONITOR_CONF_BLOCK = 8
15-
FMCHARGE_CONTROLLER_BLOCK = 9
16-
BASIC_CHARGE_CONTROLLER_BLOCK = 10
13+
BATTERY_MONITOR_BLOCK = 9
14+
BATTERY_MONITOR_CONF_BLOCK = 10
15+
FMCHARGE_CONTROLLER_BLOCK = 8
16+
BASIC_CHARGE_CONTROLLER_BLOCK = 7
1717
END_BLOCK = 11
1818

1919
blocks_name = {

wrapper_python/outback/block_conf.pyc

1.24 KB
Binary file not shown.

wrapper_python/outback/blocks.py

100644100755
File mode changed.

wrapper_python/outback/blocks.pyc

15.9 KB
Binary file not shown.

wrapper_python/outback/inverter.py

100644100755
File mode changed.

wrapper_python/outback/inverter.pyc

2.88 KB
Binary file not shown.

wrapper_python/outback/outback

121 KB
Binary file not shown.

wrapper_python/outback/outback.py

100644100755
File mode changed.

wrapper_python/outback/outback_blocks_register.py

100644100755
File mode changed.

wrapper_python/outback/outback_functions.py

100644100755
File mode changed.

wrapper_python/outback/outback_register.py

100644100755
+14-16
Original file line numberDiff line numberDiff line change
@@ -15,47 +15,45 @@ def __init__(self, name, field, block, unit=""):
1515
self.unit = unit
1616

1717
def read_reg(self, ip, port=""):
18-
result = subprocess.Popen(["outback", "-r", "-c", ip, "-f", self.field, "-b", self.block]
19-
, stdout=subprocess.PIPE)
18+
result = subprocess.Popen(["./program", "-r", "-c", str(ip), "-f", str(self.field), "-b", str(self.block)],stdout=subprocess.PIPE)
2019
out, err = result.communicate()
21-
logger.info("Output " + out + " error " + err)
20+
logger.info("Output " + str(out) + " error " + str(err))
2221
#TODO check error handling to check if register read fails.
2322
return out
2423

2524
def write_reg(self, value, ip, port=""):
26-
result = subprocess.Popen(["outback", "-w", "-c", ip, "-f", self.field, "-b", self.block, "-v", value]
27-
, stdout=subprocess.PIPE)
25+
result = subprocess.Popen(["./program", "-w", "-c", str(ip), "-f", str(self.field), "-b", str(self.block), "-v", str(value)], stdout=subprocess.PIPE)
2826
out, err = result.communicate()
29-
logger.info("Output " + out + " error " + err)
27+
logger.info("Output " + str(out) + " error " + str(err))
3028
#TODO check error handling to check if register write fails.
3129
return out
3230

3331
@staticmethod
34-
def read_multiple_reg(self, ip, fields, blocks):
32+
def read_multiple_reg( ip, fields, blocks):
3533
"""
3634
Reads multiple registers.
3735
:param fields: a comma separated string of register field values
3836
:param blocks: a comma separated string of register block values
3937
:return:
4038
"""
41-
fields_el = fields.split(',')
42-
blocks_el = blocks.split(',')
39+
fields_el = fields
40+
blocks_el = blocks
4341

44-
if fields_el != blocks_el:
45-
logger.debug("{} fields".format(fields))
46-
logger.debug("{} blocks".format(blocks))
42+
if len(fields_el) != len(blocks_el):
43+
logger.debug("{} fields".format(str(fields)))
44+
logger.debug("{} blocks".format(str(blocks)))
4745
logger.error("fields and blocks are of different lengths")
4846
return None
4947

5048
overall_out = ""
51-
for i in range(len(fields_el)):
49+
out = None
50+
for i in range(len(fields_el)):
5251
field = fields_el[i]
5352
block = blocks_el[i]
5453

55-
result = subprocess.Popen(["outback", "-m", "-c", ip, "-f", field, "-b", block]
56-
, stdout=subprocess.PIPE)
54+
result = subprocess.Popen(["./program", "-r", "-c",str(ip), "-f", str(field), "-b", str(block)], stdout=subprocess.PIPE)
5755
out, err = result.communicate()
58-
logger.info("Output " + out + " error " + err)
56+
logger.info("Output " + str(out) + " error " + str(err))
5957
overall_out = overall_out + out
6058
#TODO check error handling to check if register write fails.
6159

3.08 KB
Binary file not shown.

wrapper_python/outback/program

121 KB
Binary file not shown.

wrapper_python/outback/register_bank.py

100644100755
File mode changed.
15.5 KB
Binary file not shown.

wrapper_python/program

121 KB
Binary file not shown.

wrapper_python/test_methods.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import InverterFactory
2+
import InverterFactory as ifact
3+
ifac = ifact.InverterFactory()
4+
inv = ifac.factory()
5+
6+
reg_names = ["I_AC_Power", "I_AC_Current", "I_AC_VoltageAN","CC_Charger_State", "CC_Batt_Current", "CC_Watts", "I_AC_Frequency", "I_AC_VAR"]
7+
#OutBack_Hour #Clock Hour (0 - 23)
8+
#Outback_Minute #Clock Minute (0 - 59)
9+
#OutBack_Second #Clock Second (0 - 59)
10+
11+
inv.read_multiple(reg_names)
12+
13+
14+
def write_reg(field, block, value):
15+
16+
print "*" * 80
17+
inv.read_single(field, block)
18+
inv.write_single(field, block, value)
19+
print "*" * 80
20+
inv.read_single(field, block)
21+
22+
23+
#write_reg(366, 6 , 30)

0 commit comments

Comments
 (0)