Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add driver for GW Instek PSP series #227

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ettom
Copy link

@ettom ettom commented Oct 31, 2023

The protocol is described in the manual, available here.

Generally, everything seems to work well. One annoying limitation of the protocol/device is that it uses the same field for reporting both the actual voltage and the target voltage. This means that querying the target voltage is not possible while the output is enabled or the device is in CC mode. I did implement a heuristic to work around this as best as I could, but one corner case remains - when SmuView is launched while the output is enabled and the device is in CC mode, the target voltage will be reported as 0.00V until the output is turned on (at which point the target voltage will be updated according to the one set on the device), or until a new target voltage is set via the UI. I think that this limitation is acceptable if properly documented.

{ "GW Instek", "PSP-603", volts_60, amps_3_5 },
{ "GW Instek", "PSP-405", volts_40, amps_5 },
{ "GW Instek", "PSP-2010", volts_20, amps_10 },
ALL_ZERO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to NULL-terminate your array when you use ARRAY_SIZE to iterate over it.

sr_dbg("Found: [%s] [%s]", check->vendor, check->name);
return check;
}
sr_dbg("Not found");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The three debug messages seem a bit much, considering it's an in-memory lookup with almost hardcoded input (the force_detect value).

serialcomm = "2400/8n1";
if (!force_detect) {
sr_err("The gwinstek-psp driver requires the force_detect parameter");
return NULL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this hardware really provide no way at all to detect the model? What does the vendor-provided software do?

devc->next_req_time = 0;
devc->set_voltage_target_updated = 0;
devc->voltage_target_updated = 0;
devc->last_status_query_time = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You specifically used g_malloc0, so no need to initialize devc members to 0.

if (dval < devc->model->voltage[0] || dval > devc->model->voltage[1])
return SR_ERR_ARG;


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't leave double blank lines anywhere in the source.

@biot
Copy link
Contributor

biot commented Sep 27, 2024

Sorry about the long delay in getting this reviewed, I hope you still want to get this driver merged. The code looks good, aside from the minor changes. Seems like a challenging device to write a driver for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants