Skip to content

Commit

Permalink
CInterface: clarify arrays vs. pointers
Browse files Browse the repository at this point in the history
This is mainly motivated by the LabVIEW import wizard getting confused
by single-item pointers that are actually arrays.
  • Loading branch information
willeccles committed May 17, 2024
1 parent e1061c0 commit fcb21e3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 34 deletions.
38 changes: 20 additions & 18 deletions include/bci/abs/CInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,13 @@ int AbsScpiClient_SetIPAddress(AbsScpiClientHandle handle,
const AbsEthernetConfig* addr);

// buffer is not modified on error
int AbsScpiClient_GetCalibrationDate(AbsScpiClientHandle handle, char* buf,
int AbsScpiClient_GetCalibrationDate(AbsScpiClientHandle handle, char buf[],
unsigned int len);

int AbsScpiClient_GetErrorCount(AbsScpiClientHandle handle, int* count_out);

int AbsScpiClient_GetNextError(AbsScpiClientHandle handle,
int16_t* err_code_out, char* msg_buf,
int16_t* err_code_out, char msg_buf[],
unsigned int msg_buf_len);

int AbsScpiClient_ClearErrors(AbsScpiClientHandle handle);
Expand Down Expand Up @@ -206,63 +206,64 @@ int AbsScpiClient_SetCellVoltage(AbsScpiClientHandle handle, unsigned int cell,
float voltage);

int AbsScpiClient_SetAllCellVoltage(AbsScpiClientHandle handle,
const float* voltages, unsigned int count);
const float voltages[], unsigned int count);

int AbsScpiClient_GetCellVoltageTarget(AbsScpiClientHandle handle,
unsigned int cell, float* voltage_out);

int AbsScpiClient_GetAllCellVoltageTarget(AbsScpiClientHandle handle,
float* voltages_out,
float voltages_out[],
unsigned int count);

int AbsScpiClient_SetCellSourcing(AbsScpiClientHandle handle, unsigned int cell,
float limit);

int AbsScpiClient_SetAllCellSourcing(AbsScpiClientHandle handle,
const float* limits, unsigned int count);
const float limits[], unsigned int count);

int AbsScpiClient_GetCellSourcingLimit(AbsScpiClientHandle handle,
unsigned int cell, float* limit_out);

int AbsScpiClient_GetAllCellSourcingLimit(AbsScpiClientHandle handle,
float* limits_out,
float limits_out[],
unsigned int count);

int AbsScpiClient_SetCellSinking(AbsScpiClientHandle handle, unsigned int cell,
float limit);

int AbsScpiClient_SetAllCellSinking(AbsScpiClientHandle handle,
const float* limits, unsigned int count);
const float limits[], unsigned int count);

int AbsScpiClient_GetCellSinkingLimit(AbsScpiClientHandle handle,
unsigned int cell, float* limit_out);

int AbsScpiClient_GetAllCellSinkingLimit(AbsScpiClientHandle handle,
float* limits_out, unsigned int count);
float limits_out[],
unsigned int count);

int AbsScpiClient_SetCellFault(AbsScpiClientHandle handle, unsigned int cell,
int fault);

int AbsScpiClient_SetAllCellFault(AbsScpiClientHandle handle, const int* faults,
unsigned int count);
int AbsScpiClient_SetAllCellFault(AbsScpiClientHandle handle,
const int faults[], unsigned int count);

int AbsScpiClient_GetCellFault(AbsScpiClientHandle handle, unsigned int cell,
int* fault_out);

int AbsScpiClient_GetAllCellFault(AbsScpiClientHandle handle, int* faults_out,
int AbsScpiClient_GetAllCellFault(AbsScpiClientHandle handle, int faults_out[],
unsigned int count);

int AbsScpiClient_SetCellSenseRange(AbsScpiClientHandle handle,
unsigned int cell, int range);

int AbsScpiClient_SetAllCellSenseRange(AbsScpiClientHandle handle,
const int* ranges, unsigned int count);
const int ranges[], unsigned int count);

int AbsScpiClient_GetCellSenseRange(AbsScpiClientHandle handle,
unsigned int cell, int* range_out);

int AbsScpiClient_GetAllCellSenseRange(AbsScpiClientHandle handle,
int* ranges_out, unsigned int count);
int ranges_out[], unsigned int count);

int AbsScpiClient_SetCellPrecisionMode(AbsScpiClientHandle handle, int mode);

Expand All @@ -273,33 +274,34 @@ int AbsScpiClient_MeasureCellVoltage(AbsScpiClientHandle handle,
unsigned int cell, float* voltage_out);

int AbsScpiClient_MeasureAllCellVoltage(AbsScpiClientHandle handle,
float* voltages_out,
float voltages_out[],
unsigned int count);

int AbsScpiClient_MeasureCellCurrent(AbsScpiClientHandle handle,
unsigned int cell, float* current_out);

int AbsScpiClient_MeasureAllCellCurrent(AbsScpiClientHandle handle,
float* currents_out,
float currents_out[],
unsigned int count);

int AbsScpiClient_GetCellOperatingMode(AbsScpiClientHandle handle,
unsigned int cell, int* mode_out);

int AbsScpiClient_GetAllCellOperatingMode(AbsScpiClientHandle handle,
int* modes_out, unsigned int count);
int modes_out[], unsigned int count);

int AbsScpiClient_SetAnalogOutput(AbsScpiClientHandle handle,
unsigned int channel, float voltage);

int AbsScpiClient_SetAllAnalogOutput(AbsScpiClientHandle handle,
const float* voltages, unsigned int count);
const float voltages[],
unsigned int count);

int AbsScpiClient_GetAnalogOutput(AbsScpiClientHandle handle,
unsigned int channel, float* voltage_out);

int AbsScpiClient_GetAllAnalogOutput(AbsScpiClientHandle handle,
float* voltages_out, unsigned int count);
float voltages_out[], unsigned int count);

#ifdef __cplusplus
}
Expand Down
33 changes: 17 additions & 16 deletions src/CInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ int AbsScpiClient_SetCellVoltage(AbsScpiClientHandle handle, unsigned int cell,
}

int AbsScpiClient_SetAllCellVoltage(AbsScpiClientHandle handle,
const float* voltages, unsigned int count) {
const float voltages[],
unsigned int count) {
return WrapSet(&sc::SetAllCellVoltage, handle, voltages,
static_cast<std::size_t>(count));
}
Expand All @@ -276,7 +277,7 @@ int AbsScpiClient_GetCellVoltageTarget(AbsScpiClientHandle handle,
}

int AbsScpiClient_GetAllCellVoltageTarget(AbsScpiClientHandle handle,
float* voltages_out,
float voltages_out[],
unsigned int count) {
return WrapGet(&sc::GetAllCellVoltageTarget, handle, voltages_out,
static_cast<std::size_t>(count));
Expand All @@ -288,7 +289,7 @@ int AbsScpiClient_SetCellSourcing(AbsScpiClientHandle handle, unsigned int cell,
}

int AbsScpiClient_SetAllCellSourcing(AbsScpiClientHandle handle,
const float* limits, unsigned int count) {
const float limits[], unsigned int count) {
return WrapSet(&sc::SetAllCellSourcing, handle, limits,
static_cast<std::size_t>(count));
}
Expand All @@ -299,7 +300,7 @@ int AbsScpiClient_GetCellSourcingLimit(AbsScpiClientHandle handle,
}

int AbsScpiClient_GetAllCellSourcingLimit(AbsScpiClientHandle handle,
float* limits_out,
float limits_out[],
unsigned int count) {
return WrapGet(&sc::GetAllCellSourcingLimit, handle, limits_out,
static_cast<std::size_t>(count));
Expand All @@ -311,7 +312,7 @@ int AbsScpiClient_SetCellSinking(AbsScpiClientHandle handle, unsigned int cell,
}

int AbsScpiClient_SetAllCellSinking(AbsScpiClientHandle handle,
const float* limits, unsigned int count) {
const float limits[], unsigned int count) {
return WrapSet(&sc::SetAllCellSinking, handle, limits,
static_cast<std::size_t>(count));
}
Expand All @@ -322,7 +323,7 @@ int AbsScpiClient_GetCellSinkingLimit(AbsScpiClientHandle handle,
}

int AbsScpiClient_GetAllCellSinkingLimit(AbsScpiClientHandle handle,
float* limits_out,
float limits_out[],
unsigned int count) {
return WrapGet(&sc::GetAllCellSinkingLimit, handle, limits_out,
static_cast<std::size_t>(count));
Expand All @@ -342,8 +343,8 @@ int AbsScpiClient_SetCellFault(AbsScpiClientHandle handle, unsigned int cell,
static_cast<CellFault>(fault));
}

int AbsScpiClient_SetAllCellFault(AbsScpiClientHandle handle, const int* faults,
unsigned int count) {
int AbsScpiClient_SetAllCellFault(AbsScpiClientHandle handle,
const int faults[], unsigned int count) {
return WrapSet(&sc::SetAllCellFault, handle,
reinterpret_cast<const CellFault*>(faults),
static_cast<std::size_t>(count));
Expand All @@ -355,7 +356,7 @@ int AbsScpiClient_GetCellFault(AbsScpiClientHandle handle, unsigned int cell,
reinterpret_cast<CellFault*>(fault_out), cell);
}

int AbsScpiClient_GetAllCellFault(AbsScpiClientHandle handle, int* faults_out,
int AbsScpiClient_GetAllCellFault(AbsScpiClientHandle handle, int faults_out[],
unsigned int count) {
return WrapGet(&sc::GetAllCellFault, handle,
reinterpret_cast<CellFault*>(faults_out),
Expand All @@ -377,7 +378,7 @@ int AbsScpiClient_SetCellSenseRange(AbsScpiClientHandle handle,
}

int AbsScpiClient_SetAllCellSenseRange(AbsScpiClientHandle handle,
const int* ranges, unsigned int count) {
const int ranges[], unsigned int count) {
return WrapSet(&sc::SetAllCellSenseRange, handle,
reinterpret_cast<const CellSenseRange*>(ranges),
static_cast<std::size_t>(count));
Expand All @@ -390,7 +391,7 @@ int AbsScpiClient_GetCellSenseRange(AbsScpiClientHandle handle,
}

int AbsScpiClient_GetAllCellSenseRange(AbsScpiClientHandle handle,
int* ranges_out, unsigned int count) {
int ranges_out[], unsigned int count) {
return WrapGet(&sc::GetAllCellSenseRange, handle,
reinterpret_cast<CellSenseRange*>(ranges_out),
static_cast<std::size_t>(count));
Expand Down Expand Up @@ -421,7 +422,7 @@ int AbsScpiClient_MeasureCellVoltage(AbsScpiClientHandle handle,
}

int AbsScpiClient_MeasureAllCellVoltage(AbsScpiClientHandle handle,
float* voltages_out,
float voltages_out[],
unsigned int count) {
return WrapGet(&sc::MeasureAllCellVoltage, handle, voltages_out,
static_cast<std::size_t>(count));
Expand All @@ -433,7 +434,7 @@ int AbsScpiClient_MeasureCellCurrent(AbsScpiClientHandle handle,
}

int AbsScpiClient_MeasureAllCellCurrent(AbsScpiClientHandle handle,
float* currents_out,
float currents_out[],
unsigned int count) {
return WrapGet(&sc::MeasureAllCellCurrent, handle, currents_out,
static_cast<std::size_t>(count));
Expand All @@ -451,7 +452,7 @@ int AbsScpiClient_GetCellOperatingMode(AbsScpiClientHandle handle,
}

int AbsScpiClient_GetAllCellOperatingMode(AbsScpiClientHandle handle,
int* modes_out, unsigned int count) {
int modes_out[], unsigned int count) {
return WrapGet(&sc::GetAllCellOperatingMode, handle,
reinterpret_cast<CellMode*>(modes_out),
static_cast<std::size_t>(count));
Expand All @@ -463,7 +464,7 @@ int AbsScpiClient_SetAnalogOutput(AbsScpiClientHandle handle,
}

int AbsScpiClient_SetAllAnalogOutput(AbsScpiClientHandle handle,
const float* voltages,
const float voltages[],
unsigned int count) {
return WrapSet(&sc::SetAllAnalogOutput, handle, voltages,
static_cast<std::size_t>(count));
Expand All @@ -475,7 +476,7 @@ int AbsScpiClient_GetAnalogOutput(AbsScpiClientHandle handle,
}

int AbsScpiClient_GetAllAnalogOutput(AbsScpiClientHandle handle,
float* voltages_out, unsigned int count) {
float voltages_out[], unsigned int count) {
return WrapGet(&sc::GetAllAnalogOutput, handle, voltages_out,
static_cast<std::size_t>(count));
}

0 comments on commit fcb21e3

Please sign in to comment.