starting to decode messages
This commit is contained in:
parent
9ee3c08e9b
commit
978d494845
3 changed files with 19 additions and 6 deletions
2
.idea/BMS View.iml
generated
2
.idea/BMS View.iml
generated
|
|
@ -4,7 +4,7 @@
|
|||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="jdk" jdkName="Python 2.7 (BMS-View)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="R User Library" level="project" />
|
||||
<orderEntry type="library" name="R Skeletons" level="application" />
|
||||
|
|
|
|||
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 2.7 (BMS View)" project-jdk-type="Python SDK" />
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 2.7 (BMS-View)" project-jdk-type="Python SDK" />
|
||||
</project>
|
||||
21
Main.py
21
Main.py
|
|
@ -2,13 +2,26 @@ import Messages
|
|||
import time
|
||||
from PCANBasic import *
|
||||
|
||||
|
||||
PCAN = PCANBasic()
|
||||
cV = []
|
||||
PCAN = PCANBasic() # type: PCANBasic
|
||||
res = PCAN.Initialize(PCAN_USBBUS1, PCAN_BAUD_500K)
|
||||
|
||||
while True:
|
||||
PCAN.Write(PCAN_USBBUS1, Messages.rCellVinit)
|
||||
PCAN.Write(PCAN_USBBUS1, Messages.rCellVInit)
|
||||
time.sleep(.050)
|
||||
cellMessage = False # type: bool
|
||||
# Keep reading messages until a cell voltage message is received
|
||||
while (cellMessage == False):
|
||||
MSG = PCAN.Read(PCAN_USBBUS1)
|
||||
if MSG.ID == 0x7bb:
|
||||
cellMessage = True
|
||||
v1 = "%s%s" % (MSG.DATA[4], MSG.DATA[5])
|
||||
v2 = "%s%s" % (MSG.DATA[6], MSG.DATA[7])
|
||||
v1 = int(v1, 16)
|
||||
v2 = int(v2, 16)
|
||||
print(v1)
|
||||
print(v2)
|
||||
|
||||
for i in range(18):
|
||||
PCAN.Write(PCAN_USBBUS1, Messages.rCellV)
|
||||
time.sleep(.050)
|
||||
time.sleep(.050);
|
||||
Loading…
Add table
Reference in a new issue