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

Implement Flipper SubGHz v1 input format #192

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pllopis
Copy link

@pllopis pllopis commented Aug 22, 2022

This PR provides a new input module that adds support to read Flipper Zero generated raw .sub (SubGHz) signal files.

These files are saved by the Flipper Zero when using the Read RAW function.

These files follow a simple format. Any .sub file contains a single channel with the logical (de-modulated) signal. The raw data represents the duration (in micro seconds) for either logical high (duration as a positive integer) or logical low (duration as a negative integer).

Examples of these .sub files can be found all over the net, e.g. https://github.com/MuddledBox/FlipperZeroSub-GHz/blob/main/Vehicles/Tesla/Tesla_charge_door_AM270.sub

@pllopis
Copy link
Author

pllopis commented Feb 4, 2023

friendly bump :)

}

sr_dbg("logical %d duration %ld", logic, num_samples);
ret = feed_queue_logic_submit(inc->feed_logic, &logic, num_samples);
Copy link
Contributor

Choose a reason for hiding this comment

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

The internal API has changed this call to feed_queue_logic_submit_one() (same parameters), so this no longer works.

sr_dbg("Flipper SubGHz version 1 file format detected");
return TRUE;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

These three functions should just be reduced to an inline g_strstr_len() call.

num_values = g_strv_length(values);
sr_dbg("Line contains %d raw values", num_values);
for (int i = 0; i < num_values; i++) {
signed long value = strtol(values[i], (char **)NULL, 10);
Copy link
Contributor

Choose a reason for hiding this comment

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

}
ret = process_value(inc, value);
if (ret != SR_OK)
return ret;
Copy link
Contributor

Choose a reason for hiding this comment

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

Forgot g_strfreev(values); here

memset(occurrence, ' ', strlen(RAW_DATA_STR));
}
int ret = parse_raw_values(inc, g_strstrip(lines[i]));
if (ret != SR_OK) {
Copy link
Contributor

Choose a reason for hiding this comment

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

See comment above wrt variable initialization/assignment.

SR_PRIV struct sr_input_module input_flipper_sub = {
.id = "flipper",
.name = "flipper",
.desc = "Flipper Sub-GHz v1",
Copy link
Contributor

@biot biot Sep 11, 2024

Choose a reason for hiding this comment

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

Flipper appears to have a bunch of file formats, and this only handles the sub-ghz v1 format. Perhaps this module should be called flipper-subghz?

@biot
Copy link
Contributor

biot commented Sep 11, 2024

Please also rebase against current master.

Lots of comments, but the code works!

Any chance of getting some example .sub files for the sigrok-dumps repo, so we can keep from regressing this module in future?

thanks

return TRUE;
}

static gboolean parse_header(GString *buf)
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 need a return value at all ? looks like it only returns TRUE

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.

4 participants