1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-02-22 12:58:36 +00:00

Merge pull request #298 from marcbonnici/revent_fixes

Revent: Fixes
This commit is contained in:
setrofim 2016-11-29 17:34:17 +00:00 committed by GitHub
commit bf43bf93bc
3 changed files with 33 additions and 13 deletions

View File

@ -422,10 +422,9 @@ recorded. The event stream is prefixed with the number of events in the stream.
Each event entry structured as follows: Each event entry structured as follows:
* A signed integer representing which device from the list of device paths * An unsigned integer representing which device from the list of device paths
this event is for (zero indexed). E.g. Device ID = 3 would be the 4th this event is for (zero indexed). E.g. Device ID = 3 would be the 4th
device in the list of device paths. device in the list of device paths.
* 32 bits of padding
* A signed integer representing the number of seconds since "epoch" when the * A signed integer representing the number of seconds since "epoch" when the
event was recorded. event was recorded.
* A signed integer representing the microseconds part of the timestamp. * A signed integer representing the microseconds part of the timestamp.

View File

@ -157,7 +157,7 @@ class RecordCommand(ReventCommand):
if args.capture_screen: if args.capture_screen:
self.logger.info("Recording screen capture") self.logger.info("Recording screen capture")
self.device.capture_screen(args.output or os.getcwdu()) self.device.capture_screen(args.output or os.getcwdu())
self.device.killall("revent", signal.SIGTERM) self.device.killall("revent", signal.SIGINT)
self.logger.info("Waiting for revent to finish") self.logger.info("Waiting for revent to finish")
while self.device.get_pids_of("revent"): while self.device.get_pids_of("revent"):
pass pass

View File

@ -226,25 +226,25 @@ void destroy_replay_device(int fd)
die("Could not destroy replay device"); die("Could not destroy replay device");
} }
inline void set_evbit(fd, bit) inline void set_evbit(int fd, int bit)
{ {
if(ioctl(fd, UI_SET_EVBIT, bit) < 0) if(ioctl(fd, UI_SET_EVBIT, bit) < 0)
die("Could not set EVBIT %i", bit); die("Could not set EVBIT %i", bit);
} }
inline void set_keybit(fd, bit) inline void set_keybit(int fd, int bit)
{ {
if(ioctl(fd, UI_SET_KEYBIT, bit) < 0) if(ioctl(fd, UI_SET_KEYBIT, bit) < 0)
die("Could not set KEYBIT %i", bit); die("Could not set KEYBIT %i", bit);
} }
inline void set_absbit(fd, bit) inline void set_absbit(int fd, int bit)
{ {
if(ioctl(fd, UI_SET_ABSBIT, bit) < 0) if(ioctl(fd, UI_SET_ABSBIT, bit) < 0)
die("Could not set ABSBIT %i", bit); die("Could not set ABSBIT %i", bit);
} }
inline void set_relbit(fd, bit) inline void set_relbit(int fd, int bit)
{ {
if(ioctl(fd, UI_SET_RELBIT, bit) < 0) if(ioctl(fd, UI_SET_RELBIT, bit) < 0)
die("Could not set RELBIT %i", bit); die("Could not set RELBIT %i", bit);
@ -562,16 +562,19 @@ void print_device_info(device_info_t *info)
int write_replay_event(FILE *fout, const replay_event_t *ev) int write_replay_event(FILE *fout, const replay_event_t *ev)
{ {
size_t ret; size_t ret;
uint64_t time;
ret = fwrite(&ev->dev_idx, sizeof(uint16_t), 1, fout); ret = fwrite(&ev->dev_idx, sizeof(uint16_t), 1, fout);
if (ret < 1) if (ret < 1)
return errno; return errno;
ret = fwrite(&ev->event.time.tv_sec, sizeof(uint64_t), 1, fout); time = (uint64_t)ev->event.time.tv_sec;
ret = fwrite(&time, sizeof(uint64_t), 1, fout);
if (ret < 1) if (ret < 1)
return errno; return errno;
ret = fwrite(&ev->event.time.tv_usec, sizeof(uint64_t), 1, fout); time = (uint64_t)ev->event.time.tv_usec;
ret = fwrite(&time, sizeof(uint64_t), 1, fout);
if (ret < 1) if (ret < 1)
return errno; return errno;
@ -1020,6 +1023,12 @@ void open_gamepad_input_devices_for_playback_or_die(input_devices_t *devices, co
devices->max_fd = fd; devices->max_fd = fd;
} }
//Used to exit program properly on termination
static volatile int EXIT = 0;
void exitHandler(int z) {
EXIT = 1;
}
void record(const char *filepath, int delay, recording_mode_t mode) void record(const char *filepath, int delay, recording_mode_t mode)
{ {
int ret; int ret;
@ -1054,6 +1063,7 @@ void record(const char *filepath, int delay, recording_mode_t mode)
} }
sigset_t old_sigset; sigset_t old_sigset;
sigemptyset(&old_sigset);
block_sigterm(&old_sigset); block_sigterm(&old_sigset);
// Write the zero size as a place holder and remember the position in the // Write the zero size as a place holder and remember the position in the
@ -1074,7 +1084,11 @@ void record(const char *filepath, int delay, recording_mode_t mode)
int32_t maxfd = 0; int32_t maxfd = 0;
int32_t keydev = 0; int32_t keydev = 0;
int i; int i;
printf("recording...\n"); printf("recording...\n");
errno = 0;
signal(SIGINT, exitHandler);
while(1) while(1)
{ {
FD_ZERO(&readfds); FD_ZERO(&readfds);
@ -1086,11 +1100,18 @@ void record(const char *filepath, int delay, recording_mode_t mode)
/* wait for input */ /* wait for input */
tout.tv_sec = delay; tout.tv_sec = delay;
tout.tv_nsec = 0; tout.tv_nsec = 0;
ret = pselect(devices.max_fd + 1, &readfds, NULL, NULL, &tout, &old_sigset); ret = pselect(devices.max_fd + 1, &readfds, NULL, NULL, &tout, &old_sigset);
if (errno == EINTR)
if (EXIT){
break; break;
if (!ret) }
if (errno == EINTR){
break; break;
}
if (!ret){
break;
}
if (wait_for_stdin && FD_ISSET(STDIN_FILENO, &readfds)) { if (wait_for_stdin && FD_ISSET(STDIN_FILENO, &readfds)) {
// in this case the key down for the return key will be recorded // in this case the key down for the return key will be recorded