7
mirror of https://github.com/EEVengers/ThunderScope.git synced 2025-04-22 17:43:44 +00:00

Send commands to PCIe hardware

This commit is contained in:
Ratan Varghese 2021-03-25 17:11:58 -04:00
parent 68f32911e8
commit d1e94e5f86
4 changed files with 29 additions and 14 deletions
Software/waveview

View File

@ -44,7 +44,7 @@ Cmd | DataSize | Name | Description
0x24 | 2 (useless) | GetTriggerCh |
0x25 | 2 (useless) | GetEdgeType |
0x31 | 4 | SetWindowSize | Data has new window size as uint32
0x32 | 2 | SetCh | Data has ch 1, 2 or 4
0x32 | 4 | SetCh | Data: `[ch1, ch2, ch3, ch4]`, each 1 or 0
0x33 | 2 | SetLevel | Data has new level
0x34 | 2 | SetTriggerCh | Data has channel 1,2,3,4
0x35 | 2 | SetEdgeType | Data has 1 (rising) or 2 (falling)

View File

@ -283,18 +283,33 @@ void controller::controllerLoop()
break;
case CMD_SetCh: {
INFO << "Packet command: SetCh";
const int packetSize = 2;
const int packetSize = 4;
if(currentPacket->dataSize != packetSize) {
ERROR << "Unexpected size for SetCh packet";
}
else {
int8_t ch = currentPacket->data[0];
if(ch == 1 || ch == 2 || ch == 4) {
setCh(currentPacket->data[0]);
int chCount = 0;
for(int i = 0; i < 4; i++) {
if(currentPacket->data[i]) {
chCount++;
}
}
if(chCount == 1 || chCount == 2 || chCount == 4) {
setCh(chCount);
}
else {
ERROR << "Bad Ch value";
ERROR << "Bad chCount for SetCh";
}
#ifndef NOHARDWARE
for(int i = 0; i < 4; i++) {
if(currentPacket->data[i]) {
hardWareCommand((int)enable_channel, i, 0, 0);
}
else {
hardWareCommand((int)disable_channel, i, 0, 0);
}
}
#endif
}
EVPacket* tempPacket = (EVPacket*) malloc(sizeof(EVPacket));
tempPacket->data = NULL;
@ -388,7 +403,9 @@ void controller::controllerLoop()
if(millivoltPerDiv < 0 || millivoltPerDiv > 10000) {
ERROR << "Bad millivoltPerDiv for SetVerticalScaling";
}
//Do something...
#ifndef NOHARDWARE
hardWareCommand((int)voltage_divison_set, ch-1, millivoltPerDiv, 0);
#endif
}
EVPacket* tempPacket = (EVPacket*) malloc(sizeof(EVPacket));
tempPacket->data = NULL;

View File

@ -119,7 +119,7 @@ export class Plumber {
bodyCheck: () => true,
cmd: CMD.CMD_SetCh,
id: 0,
writeData: [s.setCh, 0]
writeData: s.setCh
}
let setTriggerChArgs: PlumberArgs = {
headCheck: () => true,

View File

@ -1,7 +1,5 @@
import setChMode from '../configuration/enums/setChMode';
export interface SetChState {
setCh: setChMode,
setCh: number[],
setTriggerCh: number,
chOrder: number[]
}
@ -18,10 +16,10 @@ export function setChHelper(
let quadChOrder = [1, 2, 3, 4];
var chOrder = quadChOrder.filter((a, i) => chList[i] || triggerChIdx === i);
var setCh = chOrder.length as setChMode;
if(setCh === 3) {
var setCh = chList.map(x => x ? 1 : 0);
if(setCh.length === 3) {
chOrder = quadChOrder;
setCh = quadChOrder.length;
setCh = quadChOrder.map(x => (x > 0) ? 1 : 0);
}
let setTriggerCh = chOrder.indexOf(triggerCh) + 1;