Skip to content

Commit

Permalink
whitespace fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jlashner committed Mar 26, 2024
1 parent 9b2ee28 commit 9e31fcc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
32 changes: 16 additions & 16 deletions hwp_encoder/Beaglebone_Encoder_DAQ.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <pruss_intc_mapping.h>
#include <string.h>
// The rest of these libraries are for UDP service
#include <sys/types.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
Expand Down Expand Up @@ -165,7 +165,7 @@ int main(int argc, char **argv) {
// *** Configure the PRUs ***
// Run a bash file to configure the input pins
system("./pinconfig");

// Check command-line arguments
if (argc != 5) {
printf("Usage: %s Beaglebone_Encoder_DAQ Encoder1.bin \
Expand Down Expand Up @@ -205,15 +205,15 @@ int main(int argc, char **argv) {
// *** Configure memory allocation ***
// Sets memory to be used by data structures to 0
memset((struct EncoderInfo *) &encoder_packets[0], 0, sizeof(*encoder_packets));
memset((struct EncoderInfo *) &encoder_packets[1], 0, sizeof(*encoder_packets));
memset((struct EncoderInfo *) &encoder_packets[1], 0, sizeof(*encoder_packets));
memset((struct IrigInfo *) &irig_packets[0], 0, sizeof(*irig_packets));
memset((struct IrigInfo *) &irig_packets[1], 0, sizeof(*irig_packets));
memset((struct ErrorInfo *) &error_packets[0], 0, sizeof(*error_packets));
// Reset ready flags
*encoder_ready = 0;
*irig_ready = 0;
*error_ready = 0;
*error_ready = 0;

// Load code to PRU1
printf("Initializing PRU1\n");
if (argc > 2) {
Expand Down Expand Up @@ -253,7 +253,7 @@ int main(int argc, char **argv) {
printf("IP UDP TOS byte set to 0x%X\n", tos_read);
printf(" Precedence = 0x%X\n", (tos_read >> 5) & 0x7);
printf(" TOS = 0x%X\n", (tos_read >> 1) & 0xF);

// Set the timeout header
timeout_packet->header = 0x1234;
// Start stashing data into data objects to send over UDP
Expand Down Expand Up @@ -295,7 +295,7 @@ int main(int argc, char **argv) {
for (int i = 0; i < ENCODER_PACKETS_TO_SEND; i++){
encoder_to_send[i].packet_count = encd_pkt_cnt++;
}
sendto(sockfd, (struct EncoderInfo *) encoder_to_send, sizeof(encoder_to_send),
sendto(sockfd, (struct EncoderInfo *) encoder_to_send, sizeof(encoder_to_send),
MSG_CONFIRM, (const struct sockaddr *) &servaddr, sizeof(servaddr));
encd_ind = 0;
}
Expand All @@ -308,30 +308,30 @@ int main(int argc, char **argv) {
MSG_CONFIRM, (const struct sockaddr *) &servaddr, sizeof(servaddr));
irig_ind = 0;
}
// Send error data if the buffer is full
// Send error data if the buffer is full
if(err_ind == ERROR_PACKETS_TO_SEND) {
printf("%lu: sending error packets\n", curr_time);
printf("%lu: sending error packets\n", curr_time);
sendto(sockfd, (struct ErrorInfo *) error_to_send, sizeof(error_to_send), MSG_CONFIRM,
(const struct sockaddr *) &servaddr, sizeof(servaddr));
err_ind = 0;
}

// Send timeout packets if no packets have been picked up in a while
if(((double) (curr_time - encd_time))/CLOCKS_PER_SEC > ENCODER_TIMEOUT) {
printf("%lu: sending encoder timeout packet\n", curr_time);
printf("%lu: sending encoder timeout packet\n", curr_time);
timeout_packet->type = ENCODER_TIMEOUT_FLAG;
sendto(sockfd, (struct TimeoutInfo *) &timeout_packet, sizeof(*timeout_packet),
MSG_CONFIRM, (const struct sockaddr *) &servaddr, sizeof(servaddr));
// Reset the last time the encoder was monitored
encd_time = curr_time;
// Reset the last time the encoder was monitored
encd_time = curr_time;
}
if(((double) (curr_time - irig_time))/CLOCKS_PER_SEC > IRIG_TIMEOUT) {
printf("%lu: sending IRIG timeout packets\n", curr_time);
printf("%lu: sending IRIG timeout packets\n", curr_time);
timeout_packet->type = IRIG_TIMEOUT_FLAG;
sendto(sockfd, (struct TimeoutInfo *) &timeout_packet, sizeof(*timeout_packet),
MSG_CONFIRM, (const struct sockaddr *) &servaddr, sizeof(servaddr));
// Reset the last time the IRIG was monitored
irig_time = curr_time;
// Reset the last time the IRIG was monitored
irig_time = curr_time;
}
}

Expand Down
18 changes: 9 additions & 9 deletions hwp_encoder/IRIG_Detection.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,13 @@ int main(void) {
// Check for the counter overflow register
// and reset it by writing a 1
if (*IEP_TMR_GLB_STS & 1) {
(*clock_overflow)++;
(*clock_overflow)++;
*IEP_TMR_GLB_STS = 1;
}
short_edge_overflow = *clock_overflow;
}
short_edge_overflow = *clock_overflow;

// Store this sample as the new previous sample
sample = (__R31 & (1 << 14));
sample = (__R31 & (1 << 14));
ECAP.p_sample = sample;

// Total overflow time
Expand All @@ -254,7 +254,7 @@ int main(void) {
// If a falling edge, process IRIG PWM input
else {
// Store the falling edge time (accounting for overflows)
falling_edge_clock = ECAP.ts + overflow_time;
falling_edge_clock = ECAP.ts + overflow_time;
// Store the time between rising and falling edges
delta_clock = falling_edge_clock - rising_edge_clock;

Expand All @@ -266,14 +266,14 @@ int main(void) {
(delta_clock < IRIG_TIMER_1)) {
irig_bit_type = IRIG_1;
}
else if ((delta_clock > IRIG_TIMER_1) &&
else if ((delta_clock > IRIG_TIMER_1) &&
(delta_clock <= IRIG_TIMER_PI)) {
irig_bit_type = IRIG_PI;
}
else {
irig_bit_type = IRIG_ERR;
// Unexpected IRIG bit? Wait until syncing again
irig_parser_is_synched = 0;
// Unexpected IRIG bit? Wait until syncing again
irig_parser_is_synched = 0;
}

// Process IRIG synchronization and info pulses
Expand Down Expand Up @@ -326,7 +326,7 @@ int main(void) {
// Reset the synchronization
irig_parser_is_synched = 1;
irig_packets[i].clock = short_rising_edge_clock;
irig_packets[i].clock_overflow = short_rising_edge_overflow;
irig_packets[i].clock_overflow = short_rising_edge_overflow;
}
}
prev_bit_type = irig_bit_type;
Expand Down

0 comments on commit 9e31fcc

Please sign in to comment.