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

RaspiStill - DateTimeMilliseconds, USR1 Signal Handling #708

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

Conversation

sebmueller
Copy link

Adding Datetime with Millisecond, removing Delay in Timelapse, adding USR1 Signal handling

Adding Datetime with Millisecond, removing Delay in Timelapse, adding USR1 Signal handling
@JamesH65
Copy link
Collaborator

You need to get rid of the whitespace changes - they are obscuring the functionality changes.

@sebmueller
Copy link
Author

I reformated the file. Please have a look if it is better

Copy link
Contributor

@6by9 6by9 left a comment

Choose a reason for hiding this comment

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

Comments on the changes inline.

You've got 3 changes intermingled, so reviewing what each is doing is difficult. Please create it as 3 commits rather than 1.

There are also still a number of whitespace changes, and commented out code. Neither add to the readability.

I have no idea what the issue was with USRSIG1 as you've not described it, therefore it's not possible to review sensibly.

{
mode_t target_mode = 0777;
if (mkdir(dname, target_mode) == 0)
chmod(dname, target_mode);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to chmod after mkdir? My reading is that mkdir will have already set those permissions.

//create folder, if not exists
if (stat(dname, &st) == -1)
{
mode_t target_mode = 0777;
Copy link
Contributor

Choose a reason for hiding this comment

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

0777 is incredibly open. 0755 would be more normal.

vcos_sleep(CAMERA_SETTLE_TIME);
{
//vcos_sleep(CAMERA_SETTLE_TIME);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

If it's not needed, then remove it. Commenting out leaves questions as to why it is there.

@@ -1399,8 +1413,22 @@ static void store_exif_tag(RASPISTILL_STATE *state, const char *exif_tag)
* @return Returns a MMAL_STATUS_T giving result of operation
*/

MMAL_STATUS_T create_filenames(char** finalName, char** tempName, char * pattern, int frame)
MMAL_STATUS_T create_filenames(char **finalName, char **tempName, char *pattern, int frame)
Copy link
Contributor

Choose a reason for hiding this comment

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

More whitespace changes.

timeinfo = localtime(&rawtime);

*finalName = malloc(100);
*tempName = malloc(100);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we not use asprintf here, same as create_filenames, instead of mallocing a random length buffer that we're not validating is big enough.

asprintf(*finalName, "%s/img_%04d%02d%02d_%02d%02d%02d_%04d.jpg", dname, timeinfo->tm_year + 1900, timeinfo->tm_mon + 1, timeinfo->tm_mday, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec, ((int)now.tv_nsec / 1000000)); should do it (totally untested!)

strcat(*finalName, "/");
strcat(*finalName, *tempName);

if (0 > asprintf(tempName, "%s~", *finalName))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you've just leaked the 100 bytes you malloc'ed as *tempName.

if (status != MMAL_SUCCESS)
if (state.datetime)
{
status = create_filenames_datetime(&final_filename, &use_filename, state.common_settings.filename);
Copy link
Contributor

Choose a reason for hiding this comment

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

The help text for -dt / --datetime says

Replace output pattern (%d) with DateTime (MonthDayHourMinSec)

You're no longer doing that, so it's a change in behaviour. Those relying on the defined behaviour are therefore likely to see their installations break. This really needs to be a new option (with documentation).

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

Successfully merging this pull request may close these issues.

3 participants