Skip to content

Commit 723b927

Browse files
Merge pull request #22 from nasa-jpl/abrinkma-set-pl1-on-init
Abrinkma set pl1 on init
2 parents b04700e + 7e256a2 commit 723b927

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

src/jsd_egd.c

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ uint16_t jsd_egd_tlc_to_do(char tlc[2]) {
519519

520520
if (index < 0x3000 || index > 0x3FFF) {
521521
ERROR(
522-
"Two-Letter Command converstion is out of range: %s -> 0x%X not in "
522+
"Two-Letter Command conversion is out of range: %s -> 0x%X not in "
523523
"(0x3000,0x3FFF)",
524524
tlc, index);
525525
}
@@ -836,6 +836,14 @@ int jsd_egd_config_TLC_params(ecx_contextt* ecx_context, uint16_t slave_id,
836836

837837
// PL[1] does not need to be set here since it is updated synchronously
838838
// with every PDO exchange
839+
// Let's set it anyways to help head off any potential issues. Setting the
840+
// PDO-mapped max current doesn't appear to update PL[1]
841+
if (!jsd_sdo_set_param_blocking(
842+
ecx_context, slave_id, jsd_egd_tlc_to_do("PL"), 1, JSD_SDO_DATA_FLOAT,
843+
(void*)&config->egd.peak_current_limit)) {
844+
return 0;
845+
}
846+
839847

840848
if (!jsd_sdo_set_param_blocking(
841849
ecx_context, slave_id, jsd_egd_tlc_to_do("CL"), 1, JSD_SDO_DATA_FLOAT,
@@ -944,6 +952,14 @@ int jsd_egd_config_TLC_params(ecx_contextt* ecx_context, uint16_t slave_id,
944952
return 0;
945953
}
946954

955+
int32_t um = 0;
956+
if (!jsd_sdo_get_param_blocking(
957+
ecx_context, slave_id, jsd_egd_tlc_to_do("UM"), 1, JSD_SDO_DATA_U32,
958+
(void*)&um)) {
959+
return 0;
960+
}
961+
MSG("EGD[%d] UM[1] = %d", slave_id, um);
962+
947963
return 1;
948964
}
949965

@@ -1001,10 +1017,21 @@ void jsd_egd_async_sdo_process(jsd_t* self, uint16_t slave_id) {
10011017
if (!req.success) {
10021018
ERROR("Slave[%u] Failed last SDO operation on 0x%X:%u, wkc = %d",
10031019
slave_id, req.sdo_index, req.sdo_subindex, req.wkc);
1020+
}else {
1021+
1022+
// NOTE: If there is a usecase for low-frequency SDO
1023+
// Reads, EGD could parse SDO Read requests
1024+
// and update public state data here
1025+
1026+
if(req.sdo_index == jsd_egd_tlc_to_do("UM")){
1027+
MSG("EGD[%d] UM[%d] = %d (0x%X:%d set through async SDO)",
1028+
slave_id,
1029+
req.sdo_subindex,
1030+
req.data.as_i32,
1031+
req.sdo_index,
1032+
req.sdo_subindex);
1033+
}
10041034
}
1005-
// NOTE: If there is a usecase for low-frequency SDO
1006-
// Reads, EGD could parse SDO Read requests
1007-
// and update public state data here
10081035
}
10091036

10101037
// 2) Check if any SDO operations are ongoing and update state

0 commit comments

Comments
 (0)