Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main()
- {
- bytes_ct=0;
- counter=0;
- total=0;
- good=0;
- bad=0;
- counterPrev=0;
- syncError=0;
- int res = (fd_spi = open("/dev/spislave", O_RDWR )); // | O_SYNC -- убрал , проверить что не похерилась работа
- if (res==-1)
- {
- printf ("error opening device. load driver first\n");
- return 0;
- }
- printf ("OK opened /dev/spislave\n");
- printf ("processing the received data...\n");
- int rawOutput=0;
- char writeEnabled =0;
- char *ptr;
- while (1)
- {
- const struct timespec req= {
- .tv_sec=0,
- .tv_nsec=1} ;
- struct timespec rem;
- nanosleep (&req,&rem);
- int ret_in = read (fd_spi, &buffer, BUFSIZE);
- if (ret_in>0)
- {
- if (writeEnabled)
- write(fd_file, &buffer, ret_in);
- } //^^ ret_in >0
- }
- close (fd_spi);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement