This commit is contained in:
Your Name
2024-04-27 03:19:19 -05:00
parent df418b503f
commit 03af7b6107
306 changed files with 108529 additions and 119 deletions

View File

@@ -0,0 +1,18 @@
#!/usr/bin/env python3
from panda import Panda
if __name__ == "__main__":
p = Panda()
p.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
p.set_gmlan(bus=2)
#p.can_send(0xaaa, b"\x00\x00", bus=3)
last_add: int | None = None
while True:
ret = p.can_recv()
if len(ret) > 0:
add = ret[0][0]
if last_add is not None and add != last_add + 1:
print("MISS: ", last_add, add)
last_add = add
print(ret)

View File

@@ -0,0 +1,36 @@
#!/usr/bin/env python3
# pylint: skip-file
# type: ignore
import numpy as np
import visa
import matplotlib.pyplot as plt
resources = visa.ResourceManager()
print(resources.list_resources())
scope = resources.open_resource('USB0::0x1AB1::0x04CE::DS1ZA184652242::INSTR', timeout=2000, chunk_size=1024000)
print(scope.query('*IDN?').strip())
#voltscale = scope.ask_for_values(':CHAN1:SCAL?')[0]
#voltoffset = scope.ask_for_values(":CHAN1:OFFS?")[0]
#scope.write(":STOP")
scope.write(":WAV:POIN:MODE RAW")
scope.write(":WAV:DATA? CHAN1")[10:]
rawdata = scope.read_raw()
data = np.frombuffer(rawdata, 'B')
print(data.shape)
s1 = data[0:650]
s2 = data[650:]
s1i = np.argmax(s1 > 100)
s2i = np.argmax(s2 > 100)
s1 = s1[s1i:]
s2 = s2[s2i:]
plt.plot(s1)
plt.plot(s2)
plt.show()
#data = (data - 130.0 - voltoffset/voltscale*25) / 25 * voltscale
print(data)

View File

@@ -0,0 +1,32 @@
#!/usr/bin/env python3
import time
from panda import Panda
p1 = Panda('380016000551363338383037')
p2 = Panda('430026000951363338383037')
# this is a test, no safety
p1.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
p2.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
# get versions
print(p1.get_version())
print(p2.get_version())
# this sets bus 2 to actually be GMLAN
p2.set_gmlan(bus=2)
# send w bitbang then without
#iden = 123
iden = 18000
#dat = "\x01\x02"
dat = "\x01\x02\x03\x04\x05\x06\x07\x08"
while 1:
iden += 1
p1.set_gmlan(bus=None)
p1.can_send(iden, dat, bus=3)
#p1.set_gmlan(bus=2)
#p1.can_send(iden, dat, bus=3)
time.sleep(0.01)
print(p2.can_recv())
#exit(0)

View File

@@ -0,0 +1,22 @@
#!/usr/bin/env python3
import time
from panda import Panda
p = Panda()
p.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
# hack anything on bus
p.set_gmlan(bus=2)
time.sleep(0.1)
while len(p.can_recv()) > 0:
print("clearing")
time.sleep(0.1)
print("cleared")
p.set_gmlan(bus=None)
iden = 18000
dat = "\x01\x02\x03\x04\x05\x06\x07\x08"
while 1:
iden += 1
p.can_send(iden, dat, bus=3)
time.sleep(0.01)

View File

@@ -0,0 +1,28 @@
#include <stdio.h>
#include <stdint.h>
#define CANPACKET_DATA_SIZE_MAX 8
#include "../../board/can_definitions.h"
#include "../../board/drivers/canbitbang.h"
int main() {
char out[300];
CANPacket_t to_bang = {0};
to_bang.addr = 20 << 18;
to_bang.data_len_code = 1;
to_bang.data[0] = 1;
int len = get_bit_message(out, &to_bang);
printf("T:");
for (int i = 0; i < len; i++) {
printf("%d", out[i]);
}
printf("\n");
printf("R:0000010010100000100010000010011110111010100111111111111111");
printf("\n");
return 0;
}