Posts by fdavid • 351 points
24 posts
-
0
votes2
answers1434
viewsA: What are the best practices for working with Legacy Database in Django?
Database views can also be used in your models, so include in inspectdb the --include-views parameter, however, provide the inclusion of a primary key in your views, as @mgibsonbr already mentioned,…
-
1
votes1
answer79
viewsQ: Date calculation error using struct tm
My software is incremented the date in 5 minutes and works perfectly the way I am doing, Searching I found a bug that only on 16/02 of this year the calculation is not correct, follows example:…
-
1
votes0
answers20
viewsQ: Mosquitto 3.1.1 in Ubunto 18.04
When installing mosquitto by apt-get it does the installation of version 3.1, Since this version does not support the -F parameter in mosquitto_sub, present only in version 3.1.1 How to install the…
-
0
votes1
answer146
viewsQ: Compare date and time
In C I have the lib time. h to manipulate date and time, already in Arduino the class Datetime that implements some methods. I’m not finding, even if it is in the fingernail, how to compare date and…
-
0
votes1
answer237
viewsQ: Set uint8_t to int
I am receiving data and in my project storing in an array of uint8_t and then processing in variable int, it’s okay that I could leave everything int but this does not apply to the project. int…
-
1
votes1
answer42
viewsA: Calculating Date and Time
With the structure tm da lib time. h you can assign a system date or one manually, the point is that once you do some operation with your date it is necessary to validate it and this is done with…
-
0
votes1
answer42
viewsQ: Calculating Date and Time
I’m using the tm header time. h structure as follows: #include <stdio.h> #include <time.h> int main() { struct tm dt_current, dt_begin; dt_current.tm_year = 2018; dt_current.tm_mon = 11;…
-
0
votes1
answer118
viewsQ: String Return to Array
I’m making a shellscript and have the return command: $ sqlite3 banco.db 'select code from channels' 00 01 02 03 When I assign the return to a variable, everything becomes a single string. $ export…
-
1
votes0
answers30
viewsQ: Divergence in reading
I made a sketch for Arduino MEGA, where receives data by Serial2 and displays in Serial, the communication happens but the byte sent is not the same as the received, for example: Send 0x01, receive…
-
5
votes0
answers422
viewsQ: Protocol NBR 14522
I am developing software for communication with meter via serial port, and I am able to send the commands via serial, follow the codes: int serial_open(const char *device, int baud) { struct termios…
-
2
votes1
answer138
viewsQ: Edit configuration file
I have a configuration file with several parameters, example: campo1=valor campo2=valor campo3= I would like to assign a value to campo3 with Shell Script. I tried to do with awk but I couldn’t. The…
-
0
votes2
answers82
viewsA: How to work with binary data
void get_pea(char *buffer) { char lsb = buffer[0]; char msb = buffer[1]; int mb; // Modo1 (@Jefferson Quesado) mb = (msb << 8) | (lsb << 0); printf("mb 0x%x or %d\n", mb, mb); // Modo 2…
-
0
votes1
answer242
viewsQ: Treat special characters
I am treating the CURL return with SED, but as the information I receive but sometimes has the character / causes an error in the SED syntax. TOKEN=$(curl --silent $URL | awk -F '"' '/content/…
-
2
votes2
answers674
viewsQ: Treat Curl return on Linux
I am mounting a shellscript and sends a json file to a webservice, the return is as follows: {"success":false,"errorCode":3,"message":"Authenticity Token invalido"} I am tempted, using Linux…
-
0
votes2
answers82
viewsQ: How to work with binary data
I have a function in C that takes two bytes one with higher significant value (msb) and the other with lower value (lsb) and then converts them to decimal. int get_pea(char *buffer) { char lsb[8],…
-
1
votes2
answers57
viewsA: Suspend Trigger on parole
CREATE TRIGGER ... AFTER UPDATE ON table WHEN NEW.field = 1 BEGIN ... END Can also be done with more than one parole: CREATE TRIGGER ... AFTER UPDATE ON table WHEN NEW.field = 1 AND (SELECT COUNT(*)…
-
3
votes2
answers57
viewsQ: Suspend Trigger on parole
I did not find a SQL statenment IF in Sqlite and the closest was the CASE, that this attending me, meanwhile would like to suspend a Trigger upon a conditional and believe that can only be done with…
-
0
votes2
answers222
viewsQ: Format year on Sqlite
I need to format a timestamp in the following format: DDMMYYHHMMSS I got it using the strftime, example: select strftime("%d%m%Y%H%M%S", current_timestamp) from stream; But this way it shows 4…
-
1
votes0
answers49
viewsQ: How to check a CRC
I get 9 bytes per serial where the last two are CRC-16, I need to check this CRC to know if I received the block correctly. buffer[0] = 0x2E; buffer[1] = 0x83; buffer[2] = 0x82; buffer[3] = 0x00;…
-
2
votes1
answer60
viewsQ: Using Linux libraries
I am developing a software in C that receives information and need to verify that it is correct through a CRC-16, searching found a lib only for CRC called libcrc.org but also found something on…
-
2
votes1
answer135
views -
2
votes1
answer737
views -
0
votes2
answers329
viewsA: Size of a dynamic array
Thank you for your contributions, in your example Lacobus in my project would not work because I do not know the size of the array when creating and I always relocate (realloc) but I remembered…
-
0
votes2
answers329
viewsQ: Size of a dynamic array
I’m testing with dynamic memory allocation, but when I try to get the array size I always get the same result. int main() { int *teste=malloc(sizeof(int) * 10); int len=sizeof(teste) / sizeof(int);…