diff options
| author | kutayboz <kutayboz@gmail.com> | 2023-06-06 20:03:51 +0300 |
|---|---|---|
| committer | kutayboz <kutayboz@gmail.com> | 2023-06-06 20:03:51 +0300 |
| commit | e3460fb4598cc1460d6c6c7e48ccebaec6b4b119 (patch) | |
| tree | 88e1a557349f3a42f6b4fb2ef0f1df8a04cc3d94 /src/main.c | |
| parent | addad212bbf05f6599fea747ebae945cb16e5d96 (diff) | |
| download | celnetmon-e3460fb4598cc1460d6c6c7e48ccebaec6b4b119.tar.gz | |
Compiler parameters correction and resulting fixes.
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -1,6 +1,8 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <time.h> +#include <unistd.h> #include <gpio.h> #include <serial.h> @@ -8,7 +10,7 @@ int main() { char *commandList[] = {"AT", "ATI", "AT+COPS?", "AT+COPS=?"}, - serialFilePath[] = "/dev/serial0", *output = malloc(1); + serialFilePath[] = "/dev/serial0", *output; int serialPort, moduleStatus; unsigned long idx; @@ -17,14 +19,11 @@ int main() { moduleStatus = checkPinVal(27); if (0 > moduleStatus) { printf("Error checkPinVal()\n"); - close(serialPort); - free(output); return 1; } else if (moduleStatus == 0) { printf("Module is off\nPowering on\n"); if (0 != modemPowerToggle(17)) { printf("Error toggling modem power\n"); - free(output); return 1; } pwrKeyTime = time(NULL); @@ -32,7 +31,6 @@ int main() { sleep(1); if (time(NULL) - pwrKeyTime > 10) { printf("Modem power on takes longer than 10s\nAborting\n"); - free(output); return 1; } } @@ -41,10 +39,10 @@ int main() { serialPort = openSerialPort(serialFilePath); if (serialPort < 0) { printf("Error openSerialPort()\n"); - free(output); return 1; } + output = malloc(1); for (idx = 0; idx < sizeof(commandList) / sizeof(*commandList); idx++) { if (0 != querySerialPort(&output, serialPort, commandList[idx])) { printf("Error querySerialPort()\n"); |
