diff options
author | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-08-14 10:32:21 -0400 |
---|---|---|
committer | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-08-14 10:32:21 -0400 |
commit | cc81ed5ed18464d6e632c79a1ccc9a2a8eea45b4 (patch) | |
tree | f6c1168e533fe28859269c111864ce82f88a8300 | |
parent | 1d122d034def5e9f7e0a76159866de0f36ab56f7 (diff) |
astyle formatting run
-rw-r--r-- | error_utils.c | 2 | ||||
-rw-r--r-- | globals.c | 4 | ||||
-rw-r--r-- | i2c.c | 42 | ||||
-rw-r--r-- | instr-client.c | 11 | ||||
-rw-r--r-- | lcd.c | 14 | ||||
-rw-r--r-- | parser.c | 7 | ||||
-rw-r--r-- | response.c | 11 | ||||
-rw-r--r-- | string_utils.c | 11 |
8 files changed, 56 insertions, 46 deletions
diff --git a/error_utils.c b/error_utils.c index ab44893..73d2999 100644 --- a/error_utils.c +++ b/error_utils.c @@ -209,7 +209,7 @@ void format_error_text (gchar **response, int error_type, char *in) prefix=g_strdup("System error");
break;
}
-
+
*response = g_strdup_printf("%d, \"%s; %s\"", error_type, prefix, in);
g_free(prefix);
@@ -1,8 +1,8 @@ #include "globals.h" -GlobalStruct globals = { +GlobalStruct globals = { .ChannelState = {0.0}, .Flash = { "FIXME", (int)1, (char)0, (char)0 }, - .error_queue = {0}, + .error_queue = {0}, .number_of_errors = 0 }; @@ -10,45 +10,51 @@ #define I2C_BUS "/dev/i2c-3" -void I2C_Write(gulong address, guchar value) { +void I2C_Write(gulong address, guchar value) +{ struct i2c_smbus_ioctl_data argswrite; - argswrite.read_write = I2C_SMBUS_WRITE; - argswrite.size = I2C_SMBUS_BYTE; - argswrite.data = NULL; + argswrite.read_write = I2C_SMBUS_WRITE; + argswrite.size = I2C_SMBUS_BYTE; + argswrite.data = NULL; argswrite.command = value; int device = open(I2C_BUS, O_RDWR); // FIXME? - if (device == -1) return; + if (device == -1) { + return; + } ioctl(device, I2C_SLAVE, address); - ioctl(device, I2C_SMBUS, &argswrite); + ioctl(device, I2C_SMBUS, &argswrite); close(device); } -guchar I2C_Read(gulong address) { +guchar I2C_Read(gulong address) +{ union i2c_smbus_data data; - struct i2c_smbus_ioctl_data argsread; - - argsread.read_write = I2C_SMBUS_READ; - argsread.size = I2C_SMBUS_BYTE; - argsread.data = &data; - argsread.command = 0; + struct i2c_smbus_ioctl_data argsread; - int device = open(I2C_BUS, O_RDWR); + argsread.read_write = I2C_SMBUS_READ; + argsread.size = I2C_SMBUS_BYTE; + argsread.data = &data; + argsread.command = 0; - if (device == -1) return 0; + int device = open(I2C_BUS, O_RDWR); + + if (device == -1) { + return 0; + } - ioctl(device, I2C_SLAVE, address); - ioctl(device, I2C_SMBUS, &argsread); + ioctl(device, I2C_SLAVE, address); + ioctl(device, I2C_SMBUS, &argsread); - close(device); + close(device); return data.byte; } diff --git a/instr-client.c b/instr-client.c index a091d4e..c894bee 100644 --- a/instr-client.c +++ b/instr-client.c @@ -72,12 +72,13 @@ stdinAvailable (GIOChannel *source, GIOCondition condition, gpointer data) if (g_pollable_output_stream_is_writable(out) == FALSE) { g_print("stream is not writable\n"); } - + GError* error = NULL; - + written = g_pollable_output_stream_write_nonblocking(out, tmp, size, NULL, &error); - if(error != NULL && error->message) + if(error != NULL && error->message) { g_print("Got error: %s\n", error->message); + } if (written != size || written <= 0) { g_print("Could not write. blocking. Written: %d\n", written); @@ -96,7 +97,7 @@ static gboolean cbServerInput(gpointer data, gpointer additional) GPollableInputStream* inStream = (GPollableInputStream*)data; GError *error = NULL; - + size=g_pollable_input_stream_read_nonblocking(inStream, buffer, BUFSIZE, NULL, &error); if(size <=0) { terminate("Connection to server lost", -1); @@ -118,7 +119,7 @@ int main(int argc, char** argv) GError* error = NULL; GIOChannel* stdinChannel = NULL; client = g_socket_client_new(); - + /* connect to the host */ connection = g_socket_client_connect_to_host (client, (gchar*)"localhost", @@ -29,7 +29,7 @@ static void break_up_string (char *in_string, int N, char **str1, char **str2, c char *copy_input;
char *p;
- j=k=copypos=0;
+ j=k=copypos=0;
input_length=strlen(in_string);
copy_input = g_strdup(in_string);
@@ -129,7 +129,9 @@ static void LCD_RAM_write(int RAM_start,int row, int col, char *LCD_string) int ram_location;
char last_op_a_write;
- if (!LCD_string) return;
+ if (!LCD_string) {
+ return;
+ }
String_length=strlen(LCD_string);
enable_one_lcd=0x02;
@@ -256,7 +258,7 @@ void LCD_initialize(void) I2C_Write(PCF8574A+LCD_Port, 0x80);
/* wait 40us */
- g_usleep(40);
+ g_usleep(40);
LCD_clear();
@@ -266,7 +268,7 @@ void LCD_initialize(void) I2C_Write(PCF8574A+LCD_Port, 0x60);
/* wait 40us */
- g_usleep(40);
+ g_usleep(40);
I2C_Write(PCF8574A+LCD_Port, 0x00 | LCD_ENABLE);
I2C_Write(PCF8574A+LCD_Port, 0x00);
@@ -296,8 +298,8 @@ void LCD_display_error_message(char *response) LCD_write(3,0,Press_Change_Message);
g_free (row0);
- g_free (row1);
- g_free (row2);
+ g_free (row1);
+ g_free (row2);
return;
}
@@ -498,8 +498,7 @@ static int Parser_get_unit(char *parameter,char *units) if ( (parameter[i]=='e' && parameter[i+1]=='-')
|| (parameter[i]=='e' && parameter[i+1]=='+') ) {
for (i+=2; (i < strlen(parameter)) && isdigit(parameter[i]); ++i) {}
- }
- else if (parameter[i]=='e' && isdigit(parameter[i+1]) ) {
+ } else if (parameter[i]=='e' && isdigit(parameter[i+1]) ) {
for (i+=2; (i < strlen(parameter)) && isdigit(parameter[i]); ++i) {}
}
}
@@ -737,7 +736,7 @@ void Parser_main (char *in, int interactive_terminal, void(*cbfunc)(gpointer, gc }
}
- if (error_num) {
+ if (error_num) {
queue_error_from_parser(&error_response, error_num);
if (interactive_terminal) {
(*cbfunc)(user_data, error_response);
@@ -747,7 +746,7 @@ void Parser_main (char *in, int interactive_terminal, void(*cbfunc)(gpointer, gc }
g_free (response);
- g_free (error_response);
+ g_free (error_response);
if (!is_query) {
Main_update_shift_registers(); /* update values in pulse generator circuit */
@@ -61,15 +61,16 @@ gboolean cbClientInput(gpointer data, gpointer additional) GPollableOutputStream* outStream = (GPollableOutputStream*)additional; GError* error = NULL; - if(!g_pollable_input_stream_is_readable(inStream)) { return FALSE; } + if(!g_pollable_input_stream_is_readable(inStream)) { + return FALSE; + } size=g_pollable_input_stream_read_nonblocking(inStream, buffer, 1024, NULL, &error); - - if(error && error->message) - { + + if(error && error->message) { g_print_debug("Error: %s\n",error->message); return FALSE; } - + if(size <= 0) { g_print_debug("Got: %d\n", (int) size); return FALSE; diff --git a/string_utils.c b/string_utils.c index a406663..e28ccfc 100644 --- a/string_utils.c +++ b/string_utils.c @@ -34,12 +34,13 @@ void Float_To_Text(int decimal_digits,float number_in, gchar ** text_out) /*----------------------------------------------------------------------------------------------------------*/
-gboolean String_is_it_numeric(char *parameter) {
+gboolean String_is_it_numeric(char *parameter)
+{
- GRegex *numeric_regex = g_regex_new ( "\\s*[+-]?(\\d*\\.\\d+|\\d+(\\.\\d*)?)\\s*(e\\s*[+-]?\\d+)?\\s*",
- G_REGEX_CASELESS,
- 0,
- NULL);
+ GRegex *numeric_regex = g_regex_new ( "\\s*[+-]?(\\d*\\.\\d+|\\d+(\\.\\d*)?)\\s*(e\\s*[+-]?\\d+)?\\s*",
+ G_REGEX_CASELESS,
+ 0,
+ NULL);
gboolean match = g_regex_match (numeric_regex, parameter, 0, NULL);
g_regex_unref (numeric_regex);
|