USRP Hardware Driver and USRP Manual  Version: 003.008.001-0-g2474ac32
UHD and USRP Manual
status.h
Go to the documentation of this file.
1 //
2 // Copyright 2013 Ettus Research LLC
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 //
17 
18 
19 #ifndef INCLUDED_UHD_TRANSPORT_NIRIO_STATUS_H
20 #define INCLUDED_UHD_TRANSPORT_NIRIO_STATUS_H
21 
22 #include <stdio.h>
23 #include <stddef.h>
24 #include <stdint.h>
25 #include <string>
26 #include <uhd/exception.hpp>
27 
28 #define ENABLE_EXTENDED_ERROR_INFO false
29 
30 typedef int32_t nirio_status;
31 
32 namespace uhd { namespace niusrprio {
34  nirio_err_info(nirio_status arg_code, const char* arg_msg): code(arg_code), msg(arg_msg) {}
35 
37  const char* msg;
38 
40  static const size_t NIRIO_ERROR_TABLE_SIZE;
41 };
42 
43 const std::string lookup_err_msg(nirio_status code);
44 
45 void nirio_status_to_exception(const nirio_status& status, const std::string& message);
46 }}
47 
48 #define nirio_status_fatal(status) ((status) < 0)
49 #define nirio_status_not_fatal(status) ((status) >= 0)
50 
51 #define nirio_status_chain(func, status) \
52  if (nirio_status_not_fatal(status)) { \
53  status = (func); \
54  if (ENABLE_EXTENDED_ERROR_INFO && nirio_status_fatal(status)) { \
55  fprintf(stderr,"ERROR: The following function call returned status code %d\n%s\n%s:%d\n",status,#func,__FILE__,__LINE__); \
56  } \
57  } \
58 
59 
60 #define NIRIO_ERR_INFO(CONST_NAME, ERR_CODE, ERR_MSG) \
61  static const nirio_status CONST_NAME = ERR_CODE;
62 #include "nirio_err_template.h"
63 #undef NIRIO_ERR_INFO
64 
65 #endif /* INCLUDED_UHD_TRANSPORT_NIRIO_STATUS_H */
Definition: status.h:33
const char * msg
Definition: status.h:37
static const nirio_err_info NIRIO_ERROR_TABLE[]
Definition: status.h:39
const std::string lookup_err_msg(nirio_status code)
static const size_t NIRIO_ERROR_TABLE_SIZE
Definition: status.h:40
nirio_status code
Definition: status.h:36
Definition: convert.hpp:28
int32_t nirio_status
Definition: status.h:30
void nirio_status_to_exception(const nirio_status &status, const std::string &message)
Definition: msg.hpp:50
nirio_err_info(nirio_status arg_code, const char *arg_msg)
Definition: status.h:34