Cannot get SPI data using spidev

I am using TX2 with elroy carrier module. I want to just listen the SPI port for incoming data.
I have done the spi_test (source : spi_test.c) program in order to test the driver.

I jumpered the MISO and MOSI lines in order to get the data that I write before. And test succeed. I can see the data that I write.

And I started the writing some codes for reading for incoming data ;

But If I dont connect (physical) anything to the SPI port, this code reads some null bytes. read() system call returns 32 bytes but these are just zero… After then, I connected a device to the SPI port, then this code gives the same results. It is just reading all zeroes.

According to my knowledgement, read() system call blocked if there is nothing to read. For example, when I am reading the PCI port, If I disconnect the PCI device, read() stops here and waits for the incoming data. But when reading the SPI port, read() not blocked, just reading null bytes.

The code that I tried ;

    int main(int argc, char **argv) 
        int i,fd;
        char wr_buf[]={0xff,0x00,0x1f,0x0f};
        char rd_buf[32];

        fd = open("/dev/spidev0.0", O_RDWR);
        if (fd<=0) { 
            printf("%s: Device %s not found\n", argv[0], argv[1]);
            // just read the incoming data..
            if (read(fd, rd_buf, ARRAY_SIZE(rd_buf)) != ARRAY_SIZE(rd_buf))
                perror("Read Error");
                for (i=0;i<ARRAY_SIZE(rd_buf);i++) 
                    printf("0x%02X ", rd_buf[i]);

        return 0;

Some points ;

  • spidev_test succed.
  • cat /dev/spidev0.0 gives error : Message too long
  • Device is listed in /dev/ as /dev/spidev0.0. Open system call is not failing when opening this.
  • I have also tried use the ioctl version (with connecting the real (physical) device). (spidev_fdx.c)
  • My main goal is reading the data from CAN bus with CAN-SPI board which uses MCP2515 chip. (click for the details of the device)

I cannot solve the problem. Do you have any ideas ?