The code
Embedded Linux C. It compiles. There are 3 real bugs in it: the kind that pass a bench test and fail in the field.
int adc_read(int fd, int ch, uint16_t *out)
{
uint8_t tx[3] = { 0x01, (uint8_t)((8 + ch) << 4), 0x00 };
uint8_t rx[3];
struct spi_ioc_transfer t;
t.tx_buf = (unsigned long)tx;
t.rx_buf = (unsigned long)rx;
t.len = 3;
t.speed_hz = 1000000;
ioctl(fd, SPI_IOC_MESSAGE(1), &t);
*out = (uint16_t)(((rx[1] & 0x03) << 8) | rx[2]);
return 0;
}What an interviewer expects
- Point to each line you'd stop in a code review.
- Say what actually breaks: the failure mode, not just the rule it violates.
- Fix it, then defend the fix when asked the follow-up.
The bugs, reference fixes and the follow-up question are in the practice app, after you've tried it.
Companies that test this
Matched on the skills each company's embedded roles emphasise.
AptivAutomotive supplier · India hiring: MediumCapgemini EngineeringEngineering services · India hiring: HighCyientEngineering services · India hiring: MediumInfosys Engineering ServicesEngineering services · India hiring: HighL&T Technology ServicesEngineering services · India hiring: HighMarvellChipmaker · India hiring: MediumMercedes-Benz R&D IndiaAutomotive OEM R&D · India hiring: HighSchneider ElectricIndustrial · India hiring: High
Related challenges
Character driver read()Embedded Linux · Medium · 3 bugs · ~7 minSerial GPS reader on LinuxEmbedded Linux · Medium · 4 bugs · ~6 minPing diagnostic on a Linux gatewayEmbedded Linux · Medium · 3 bugs · ~6 minGPIO through /dev/memEmbedded Linux · Medium · 3 bugs · ~6 minTouch driver interrupt handlerEmbedded Linux · Hard · 3 bugs · ~7 min
Flag the lines, say what breaks, then fix it and build it with clang in your browser.
Find the bugs