embedded

problems with fread() always returning 1

非 Y 不嫁゛ 提交于 2019-12-01 07:07:57
问题 I have looked at similar questions, but mine is a bit different. I make sure to open file in binary mode and to check if error occurs while reading. File contents: message1, message2, 53467 program to read simple file: int bytesRead; FILE* CSV; CSV = fopen("\\Temp\\csv.txt", "rb"); char dataBuf[128]; while ( (bytesRead = fread(dataBuf, 1, sizeof(dataBuf), CSV) > 0) ) { if (ferror(CSV)) //handle error //do stuff with dataBuf contents } fread() is always returning 1. ferror is also not entered,

structs with uint8_t on a MCU without uint8_t datatype

怎甘沉沦 提交于 2019-12-01 05:20:11
I am an Embedded Software developer and I want to interface to an external device. This device sends data via SPI. The structure of that data is predefined from the external device manufacturer and can't be edited. The manufacturer is providing some Header files with many typedefs of all the data send via SPI. The manufacturer also offers an API to handle the received packets in the correct way(I have access to the source of that API). Now to my problem: The typedefed structures contain many uint8_t datatypes. Unfortunately, our MCU doesn't support uint8_t datatypes, because the smallest type

Initialising int affects function return value

我是研究僧i 提交于 2019-12-01 04:44:08
问题 Sorry for the vagueness of this question's title, but I'm not sure how to ask this exactly. The following code, when executed on an Arduino microprocessor (c++ compiled for an ATMega328 microprocessor) works fine. Return values shows in comments in the code: // Return the index of the first semicolon in a string int detectSemicolon(const char* str) { int i = 0; Serial.print("i = "); Serial.println(i); // prints "i = 0" while (i <= strlen(str)) { if (str[i] == ';') { Serial.print("Found at i =

Can ARM qemu system emulator boot from card image without kernel param?

感情迁移 提交于 2019-12-01 04:18:04
问题 I've seen a lot of examples how to run a QEMU ARM board emulator. In every case, besides SD card image param, QEMU was also always supplied with kernel param, i.e.: qemu-system-arm -M versatilepb \ -kernel vmlinuz-2.6.18-6-versatile \ #KERNEL PARAM HERE -initrd initrd.gz \ -hda hda.img -append "root=/dev/ram" I am palying with bootloaders and want to create my own bootable SD card, but don't have a real board yet and want to learn with an emulated one. However, if run as described above, QEMU

representation of MAC address in C code

寵の児 提交于 2019-12-01 04:06:55
I often see such representation of MAC address in C code: struct mac_addr { unsigned char bytes[6]; } Why necessary put an array in a structure, why not just have an array? What benefit does this provide? Thanks. You can't assign an array in C. But you can assign a struct. 来源: https://stackoverflow.com/questions/19482750/representation-of-mac-address-in-c-code

How would you approach using D in a embedded real-time environment?

两盒软妹~` 提交于 2019-12-01 03:06:56
To all those familiar with D programming language , how would go about using it in a embedded real-time environment? I understand that it's original design is not targeted for real-time embedded environments, but this question is more about how would you go about making real-time capability happen. Which constructs of the language would be indispensable? Which constructs do you see would be a problem? Has anyone successfully used it in a embedded system? Any other thoughts or suggestions would be great. D isn't really meant for use in real-time applications, mostly because some language

Getting the IEEE Single-precision bits for a float

五迷三道 提交于 2019-12-01 00:50:28
I need to write an IEEE single-precision floating point number to a 32-bit hardware register at a particular address. To do that, I need to convert a variable of type float to an unsigned integer. I can get the integer representation like this: float a = 2.39; unsigned int *target; printf("a = %f\n",a); target = &a; printf("target = %08X\n",*target); which returns: a = 2.390000 target = 4018F5C3 All good. However this causes a compiler warning "cast.c:12: warning: assignment from incompatible pointer type" Is there any other way to do this which doesn't generate the warning? This is for

State Machine with no function pointer

﹥>﹥吖頭↗ 提交于 2019-12-01 00:33:57
I have implemented a complex state machine with numerous state transitions for a safety SIL 4 system. The back bone for this implementation was done using function pointers. When all was sailing smoothly, the V&V opposed the use of function pointers in a SIL 4 system. Reference- Rule 9 NASA .Misra C 2004 however doesnt say that function pointers cant be used. Is there any other way to implement complex state machines without any function pointers? First of all, that NASA document is not canon. Start by asking which law/directive/standard/requirement/document that enforces you to follow the

How would you approach using D in a embedded real-time environment?

只愿长相守 提交于 2019-11-30 22:16:47
问题 To all those familiar with D programming language, how would go about using it in a embedded real-time environment? I understand that it's original design is not targeted for real-time embedded environments, but this question is more about how would you go about making real-time capability happen. Which constructs of the language would be indispensable? Which constructs do you see would be a problem? Has anyone successfully used it in a embedded system? Any other thoughts or suggestions would

Output debug via printf on a Cortex-M3 CPU, stalls at BKPT instruction + confusion about JTAG and sw ports

醉酒当歌 提交于 2019-11-30 22:04:39
I have a Keil ULINK2 USB emulator box attached to the JTAG connector on my board, which is working fine with the Cortex-M3 CPU onboard (TI/Stellaris/LuminaryMicro LM3S series). It seems that both a JTAG and a SWJ-DP port share the same pins (and thus connector on your board) on these CPUs. One appears not to have ITM (printf) capability, the other does. The previous firmware people have always used stdio to UART (serial port), but I need the serial port freed up so that debug messages do not interfere with other data being sent/received to/from the serial port, thus I need for trace messages