나는 microblaze에서 ulinux로 작업하고 있습니다.SPI 용 파이프에서 읽기
Ive SPI에 약간의 문제가 있습니다. 내 코드는 파이프가 읽혀진 것을 볼 수 있습니다. 하지만 printf가 작동하지 않는 데이터 (rdata)를 어떻게 확인할 수 있습니까? 당신을 위해
# ./spiread
openend /dev/spi/pipe9
fd = 3
Initialisation complete!
try to set!
fd_set set!
Select is 1!
Wait:
Check1
Check2
* 편집 덕분에 빠른 대답 :
여기
//slavetool
int main(int argc, char **argv)
{
uint8_t rdata[1500];
int ctrl = 0;
int fd;
int pipenr = 9;
int n;
char device[15];
fd_set socks;
//open codec
sprintf(device,"/dev/spi/pipe%d", pipenr);
fd = open(device, O_RDWR);
if(fd < 0)
{
printf("Failed to open pipe %s\n", device);
return 0;
} else
{
printf("openend %s\n", device);
}
printf("fd = %i\n", fd);
printf("Initialisation complete!\n");
while(1)
{
printf("try to set!\n");
FD_ZERO(&socks);
FD_SET(fd, &socks);
printf("fd_set set!\n");
n = select(fd + 1, &socks, NULL, NULL, NULL);
//printf("Select is %i!\n", n);
if(FD_ISSET(fd, &socks))
{
ctrl = read(fd, &rdata, 1500);
printf("entered data: %s", rdata); //DOESN'T WORK
printf("ctrl: %i", ctrl); //DOESN'T WORK
printf("Check1\n"); // WORK
if(ctrl<0)
{
perror("read");
printf("Ende ctrl ist %i!\n",ctrl);
FD_ZERO(&socks);
close(fd);
return -1;
}
printf("Check2\n");
} else {printf("FD_ISSET not set");}
}
close(fd);
return 0;
}
터미널 내 코드입니다. 일하지 마! 그 print() 위로 뛰어 넘기. ** 편집 오 작품! Thx Alter Mann. -.-
내 대답의 편집을 살펴 보자, 그것은 정확하지 않았습니다 –