Changeset 604:b81293d144f0

Show
Ignore:
Timestamp:
06/11/08 11:29:46 (7 months ago)
Author:
Maxime Petazzoni <maxime.petazzoni@…>
Branch:
default
Message:

Add nx_fs_write() return value check in USB command recording.

Location:
nxos/systems/tag-route
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • nxos/systems/tag-route/main.h

    r603 r604  
    1818void replay(char *filename); 
    1919void usb_recv(void); 
    20 void usb_recv_to(fs_fd_t fd); 
     20fs_err_t usb_recv_to(fs_fd_t fd); 
    2121 
    2222#endif /* __NXOS_TAG_ROUTE_MAIN_H__ */ 
  • nxos/systems/tag-route/record.c

    r603 r604  
    4545  nx_display_string("File opened.\n"); 
    4646  nx_display_string("Waiting...\n"); 
    47   usb_recv_to(fd); 
     47 
     48  if (usb_recv_to(fd) != FS_ERR_NO_ERROR) { 
     49    nx_display_string("Error!\n"); 
     50    nx_fs_close(fd); 
     51    return; 
     52  } 
    4853 
    4954  nx_display_uint(nx_fs_get_filesize(fd)); 
  • nxos/systems/tag-route/usb.c

    r603 r604  
    6161} 
    6262 
    63 void usb_recv_to(fs_fd_t fd) { 
     63fs_err_t usb_recv_to(fs_fd_t fd) { 
    6464  U8 buf[RCMD_BUF_LEN]; 
     65  fs_err_t err; 
    6566  size_t i; 
    6667 
     
    7475 
    7576    for (i=0; i<strlen((char *)buf); i++) { 
    76       nx_fs_write(fd, buf[i]); 
     77      err = nx_fs_write(fd, buf[i]); 
     78      if (err != FS_ERR_NO_ERROR) { 
     79        return err; 
     80      } 
    7781    } 
    78     nx_fs_write(fd, (U8)'\n'); 
     82 
     83    err = nx_fs_write(fd, (U8)'\n'); 
     84    if (err != FS_ERR_NO_ERROR) { 
     85      return err; 
     86    } 
    7987 
    8088    nx_rcmd_do((char *)buf); 
    8189    nx_systick_wait_ms(50); 
    8290  } while (!streq((char *)buf, "end")); 
     91 
     92  return FS_ERR_NO_ERROR; 
    8393} 
    8494