diff options
author | Josh Blum <josh@joshknows.com> | 2010-09-23 18:32:06 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-09-23 18:32:06 -0700 |
commit | af1882ab65bb1395f75dd7a7fbdcfc8535c32479 (patch) | |
tree | 202bac56340d33396d9f666186bbc659d3d1e940 /host/lib/usrp | |
parent | 8d55b861d25671cca5011a180025bddd647b8d03 (diff) | |
download | uhd-af1882ab65bb1395f75dd7a7fbdcfc8535c32479.tar.gz uhd-af1882ab65bb1395f75dd7a7fbdcfc8535c32479.tar.bz2 uhd-af1882ab65bb1395f75dd7a7fbdcfc8535c32479.zip |
usrp1: modified control to use the c++ ifstream over fopen
Diffstat (limited to 'host/lib/usrp')
-rw-r--r-- | host/lib/usrp/usrp1/usrp1_ctrl.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/host/lib/usrp/usrp1/usrp1_ctrl.cpp b/host/lib/usrp/usrp1/usrp1_ctrl.cpp index 936ffd17d..1dc6e6e25 100644 --- a/host/lib/usrp/usrp1/usrp1_ctrl.cpp +++ b/host/lib/usrp/usrp1/usrp1_ctrl.cpp @@ -249,38 +249,39 @@ public: unsigned char buf[ep0_size]; int ret; - FILE *fp; - if ((fp = fopen(filename, "rb")) == NULL) { + std::ifstream file; + file.open(filename, std::ios::in | std::ios::binary); + if (not file.good()) { std::cerr << "cannot open fpga input file" << std::endl; - fclose(fp); + file.close(); return -1; } if (usrp_control_write_cmd(VRQ_FPGA_LOAD, 0, FL_BEGIN) < 0) { std::cerr << "fpga load error" << std::endl; - fclose(fp); + file.close(); return -1; } ssize_t n; - while ((n = fread(buf, 1, sizeof(buf), fp)) > 0) { + while ((n = file.readsome((char *)buf, sizeof(buf))) > 0) { ret = usrp_control_write(VRQ_FPGA_LOAD, 0, FL_XFER, buf, n); if (ret != n) { std::cerr << "fpga load error " << ret << std::endl; - fclose(fp); + file.close(); return -1; } } if (usrp_control_write_cmd(VRQ_FPGA_LOAD, 0, FL_END) < 0) { std::cerr << "fpga load error" << std::endl; - fclose(fp); + file.close(); return -1; } usrp_set_fpga_hash(hash); - fclose(fp); + file.close(); return 0; } |