unix网络编程卷2门代码编译中报错:error: ‘door_arg_t’ undeclared (first use in this function),环境是centos6

gcc client1.c -lunpipc -lrt -ldoor

client1.c: In function ‘main’:

client1.c:8: error: ‘door_arg_t’ undeclared (first use in this function)

client1.c:8: error: (Each undeclared identifier is reported only once

client1.c:8: error: for each function it appears in.)

client1.c:8: error: expected ‘;’ before ‘arg’

client1.c:17: error: ‘arg’ undeclared (first use in this function)

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
C++ functional中的template在编译的时候报错
template模板代码为: 1 template<class _Rx, 2 class _Arg0> _Call_wrapper<_Callable_pmd<_Rx _Arg0::*const, _Arg0> 3 mem_fn(_Rx _Arg0::*const _Pmd) 4 { // return data object wrapper 5 return (_Call_wrapper<_Callable_pmd<_Rx _Arg0::*const, _Arg0> >(_Pmd)); 6 } 所报的错误为: 错误 1 error C2143: 语法错误 : 缺少“;”(在“<”的前面) 错误 2 error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int 错误 3 error C2988: 不可识别的模板声明/定义 错误 4 error C2059: 语法错误 : “<” 错误 5 error C2653: “_Arg0”: 不是类或命名空间名称 错误 6 error C2645: 指向成员的指针没有限定名(找到“:: *”) 错误 7 fatal error C1903: 无法从以前的错误中恢复;正在停止编译 错误 8 error C2143: 语法错误 : 缺少“;”(在“<”的前面) 错误 9 error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int 错误 10 error C2988: 不可识别的模板声明/定义 错误 11 error C2059: 语法错误 : “<” 错误 12 error C2653: “_Arg0”: 不是类或命名空间名称 错误 13 error C2645: 指向成员的指针没有限定名(找到“:: *”) 错误 14 fatal error C1903: 无法从以前的错误中恢复;正在停止编译 C++在编译的时候报了一大堆错误,
SSLv2无法解析的问题,谢谢!
问题如下: ``` QString::arg: Argument missing: 无法解析SSLv2_server_method中的符号“SSLv2_server_method”:ssl, (/lib/x86_64-linux-gnu/libssl.so.1.0.0: undefined symbol: SSLv2_server_method) QString::arg: Argument missing: 无法解析SSLv2_server_method中的符号“SSLv2_server_method”:crypto, (/lib/x86_64-linux-gnu/libcrypto.so.1.0.0: undefined symbol: SSLv2_server_method) QSslSocket: cannot resolve SSLv2_server_method ``` 新手学习,差了很多资料没有找到原因,麻烦大家帮忙看看,谢谢!
CentOs6.5 32位 安装Qt5.4出错
QString::arg: Argument missing: 无法解析dbus_connection_can_send_type中的符号“dbus_connection_can_send_type”:dbus-1, (/lib/libdbus-1.so.3: undefined symbol: dbus_connection_can_send_type) QXcbWindow: Unhandled client message: "_GTK_LOAD_ICONTHEMES
关于python类的初始化问题
代码如下: class Fruit: def __init__(self,*args): for arg in args: arg(self) def has_not_harvest(self): self.has_harvest = False def setColor(color): def method(self): self.color = color return method 以上是关于类Fruit的定义,接下来实例化的时候出现问题,代码如下: apple = Fruit(has_not_harvest,setColor('green')) 求问为什么会有弹出错误显示如下: NameError: name 'has_not_harveest' is not defined![图片说明](https://img-ask.csdn.net/upload/201509/26/1443260125_373920.jpg)
最近windowsServer2008服务器总是报错重启,有没有大神能帮忙分析下dmp文件?
Microsoft (R) Windows Debugger Version 6.8.0004.0 X86 Copyright (c) Microsoft Corporation. All rights reserved. Loading Dump File [C:\Users\Administrator\Desktop\103119-9750-01.dmp] Mini Kernel Dump File: Only registers and stack trace are available Symbol search path is: SRV*C:\Symbols*http://msdl.microsoft.com/download/symbols Executable search path is: Windows Kernel Version 7601 (Service Pack 1) MP (8 procs) Free x64 Product: Server, suite: Enterprise TerminalServer SingleUserTS Built by: 7601.17514.amd64fre.win7sp1_rtm.101119-1850 Kernel base = 0xfffff800`0161e000 PsLoadedModuleList = 0xfffff800`01863e90 Debug session time: Thu Oct 31 20:30:40.829 2019 (GMT+8) System Uptime: 0 days 9:27:14.453 Loading Kernel Symbols ........................................................................................................................................... Loading User Symbols Loading unloaded module list ........ ******************************************************************************* * * * Bugcheck Analysis * * * ******************************************************************************* Use !analyze -v to get detailed debugging information. BugCheck 18, {0, fffffa800acb5070, 2, ffffffffffdff100} Probably caused by : Unknown_Image ( ANALYSIS_INCONCLUSIVE ) Followup: MachineOwner --------- 0: kd> !analyze -v ******************************************************************************* * * * Bugcheck Analysis * * * ******************************************************************************* REFERENCE_BY_POINTER (18) Arguments: Arg1: 0000000000000000, Object type of the object whose reference count is being lowered Arg2: fffffa800acb5070, Object whose reference count is being lowered Arg3: 0000000000000002, Reserved Arg4: ffffffffffdff100, Reserved The reference count of an object is illegal for the current state of the object. Each time a driver uses a pointer to an object the driver calls a kernel routine to increment the reference count of the object. When the driver is done with the pointer the driver calls another kernel routine to decrement the reference count. Drivers must match calls to the increment and decrement routines. This bugcheck can occur because an object's reference count goes to zero while there are still open handles to the object, in which case the fourth parameter indicates the number of opened handles. It may also occur when the object’s reference count drops below zero whether or not there are open handles to the object, and in that case the fourth parameter contains the actual value of the pointer references count. Debugging Details: ------------------ CUSTOMER_CRASH_COUNT: 1 DEFAULT_BUCKET_ID: DRIVER_FAULT_SERVER_MINIDUMP BUGCHECK_STR: 0x18 PROCESS_NAME: svchost.exe CURRENT_IRQL: 0 LAST_CONTROL_TRANSFER: from 0000000000000000 to 0000000000000000 STACK_TEXT: 00000000`00000000 00000000`00000000 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : 0x0 STACK_COMMAND: kb SYMBOL_NAME: ANALYSIS_INCONCLUSIVE FOLLOWUP_NAME: MachineOwner MODULE_NAME: Unknown_Module IMAGE_NAME: Unknown_Image DEBUG_FLR_IMAGE_TIMESTAMP: 0 BUCKET_ID: INVALID_KERNEL_CONTEXT Followup: MachineOwner ---------
量化交易ctp,在断开行情连接服务(api->release时)程序崩溃了
我在本机虚拟机断开行情连接完全没有问题,但放到其他的服务器上断开时就崩溃了 ``` if (this->md_user_api != nullptr) { LOG_INFO("断开行情服务"); this->connect_status = false; this->login_status = false; //this->md_user_api->RegisterSpi(NULL); this->md_user_api->Release(); this->md_user_api = NULL; } ``` 堆栈信息 ``` Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7ffb2eb42700 (LWP 5619)] pthread_join (threadid=140716587353856, thread_return=0x0) at pthread_join.c:45 45 if (INVALID_NOT_TERMINATED_TD_P (pd)) (gdb) bt #0 pthread_join (threadid=140716587353856, thread_return=0x0) at pthread_join.c:45 #1 0x00007ffff73d8b9f in CThread::Join() () from /usr/local/lib/libthostmduserapi.so #2 0x00007ffff73e1d87 in CAPISessionFactory::Stop() () from /usr/local/lib/libthostmduserapi.so #3 0x00007ffff73e3486 in CAPISessionFactory::~CAPISessionFactory() () from /usr/local/lib/libthostmduserapi.so #4 0x00007ffff7489f35 in CThostFtdcUserApiImplBase::~CThostFtdcUserApiImplBase() () from /usr/local/lib/libthostmduserapi.so #5 0x00007ffff74873d8 in CThostFtdcUserApiImpl::~CThostFtdcUserApiImpl() () from /usr/local/lib/libthostmduserapi.so #6 0x00007ffff7488217 in CThostFtdcUserApiImplBase::Release() () from /usr/local/lib/libthostmduserapi.so #7 0x00007ffff7498d82 in CFtdcMdApiImpl::Release() () from /usr/local/lib/libthostmduserapi.so #8 0x000000000047b734 in MarketSpi::CloseConnect (this=0x6e1be0) at ./MarketSpi.cpp:117 #9 0x0000000000474d30 in auto_market_connect (m=0x6e1be0) at ./main.cpp:38 #10 0x000000000047a4be in std::_Bind_simple<void (*(MarketSpi*))(MarketSpi*)>::_M_invoke<0ul>(std::_Index_tuple<0ul>) (this=0x6d3f50) at /usr/include/c++/4.8.2/functional:1732 #11 0x000000000047a361 in std::_Bind_simple<void (*(MarketSpi*))(MarketSpi*)>::operator()() (this=0x6d3f50) at /usr/include/c++/4.8.2/functional:1720 #12 0x000000000047a292 in std::thread::_Impl<std::_Bind_simple<void (*(MarketSpi*))(MarketSpi*)> >::_M_run() ( this=0x6d3f38) at /usr/include/c++/4.8.2/thread:115 #13 0x00007ffff525f070 in std::(anonymous namespace)::execute_native_thread_routine (__p=<optimized out>) at ../../../../../libstdc++-v3/src/c++11/thread.cc:84 #14 0x00007ffff7bc6e65 in start_thread (arg=0x7ffb2eb42700) at pthread_create.c:307 #15 0x00007ffff49c288d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111 ```
在训练Tensorflow模型(object_detection)时,训练在第一次评估后退出,怎么使训练继续下去?
当我进行ssd模型训练时,训练进行了10分钟,然后进入评估阶段,评估之后程序就自动退出了,没有看到误和警告,这是为什么,怎么让程序一直训练下去? 训练命令: ``` python object_detection/model_main.py --pipeline_config_path=D:/gitcode/models/research/object_detection/ssd_mobilenet_v1_coco_2018_01_28/pipeline.config --model_dir=D:/gitcode/models/research/object_detection/ssd_mobilenet_v1_coco_2018_01_28/saved_model --num_train_steps=50000 --alsologtostderr ``` 配置文件: ``` training exit after the first evaluation(only one evaluation) in Tensorflow model(object_detection) without error and waring System information What is the top-level directory of the model you are using:models/research/object_detection/ Have I written custom code (as opposed to using a stock example script provided in TensorFlow):NO OS Platform and Distribution (e.g., Linux Ubuntu 16.04):Windows-10(64bit) TensorFlow installed from (source or binary):conda install tensorflow-gpu TensorFlow version (use command below):1.13.1 Bazel version (if compiling from source):N/A CUDA/cuDNN version:cudnn-7.6.0 GPU model and memory:GeForce GTX 1060 6GB Exact command to reproduce:See below my command for training : python object_detection/model_main.py --pipeline_config_path=D:/gitcode/models/research/object_detection/ssd_mobilenet_v1_coco_2018_01_28/pipeline.config --model_dir=D:/gitcode/models/research/object_detection/ssd_mobilenet_v1_coco_2018_01_28/saved_model --num_train_steps=50000 --alsologtostderr This is my config : train_config { batch_size: 24 data_augmentation_options { random_horizontal_flip { } } data_augmentation_options { ssd_random_crop { } } optimizer { rms_prop_optimizer { learning_rate { exponential_decay_learning_rate { initial_learning_rate: 0.00400000018999 decay_steps: 800720 decay_factor: 0.949999988079 } } momentum_optimizer_value: 0.899999976158 decay: 0.899999976158 epsilon: 1.0 } } fine_tune_checkpoint: "D:/gitcode/models/research/object_detection/ssd_mobilenet_v1_coco_2018_01_28/model.ckpt" from_detection_checkpoint: true num_steps: 200000 train_input_reader { label_map_path: "D:/gitcode/models/research/object_detection/idol/tf_label_map.pbtxt" tf_record_input_reader { input_path: "D:/gitcode/models/research/object_detection/idol/train/Iframe_??????.tfrecord" } } eval_config { num_examples: 8000 max_evals: 10 use_moving_averages: false } eval_input_reader { label_map_path: "D:/gitcode/models/research/object_detection/idol/tf_label_map.pbtxt" shuffle: false num_readers: 1 tf_record_input_reader { input_path: "D:/gitcode/models/research/object_detection/idol/eval/Iframe_??????.tfrecord" } ``` 窗口输出: (default) D:\gitcode\models\research>python object_detection/model_main.py --pipeline_config_path=D:/gitcode/models/research/object_detection/ssd_mobilenet_v1_coco_2018_01_28/pipeline.config --model_dir=D:/gitcode/models/research/object_detection/ssd_mobilenet_v1_coco_2018_01_28/saved_model --num_train_steps=50000 --alsologtostderr WARNING: The TensorFlow contrib module will not be included in TensorFlow 2.0. For more information, please see: https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md https://github.com/tensorflow/addons If you depend on functionality not listed there, please file an issue. WARNING:tensorflow:Forced number of epochs for all eval validations to be 1. WARNING:tensorflow:Expected number of evaluation epochs is 1, but instead encountered eval_on_train_input_config.num_epochs = 0. Overwriting num_epochs to 1. WARNING:tensorflow:Estimator's model_fn (<function create_model_fn..model_fn at 0x0000027CBAB7BB70>) includes params argument, but params are not passed to Estimator. WARNING:tensorflow:From C:\Users\qian\Anaconda3\envs\default\lib\site-packages\tensorflow\python\framework\op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version. Instructions for updating: Colocations handled automatically by placer. WARNING:tensorflow:From C:\Users\qian\Anaconda3\envs\default\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\builders\dataset_builder.py:86: parallel_interleave (from tensorflow.contrib.data.python.ops.interleave_ops) is deprecated and will be removed in a future version. Instructions for updating: Use tf.data.experimental.parallel_interleave(...). WARNING:tensorflow:From C:\Users\qian\Anaconda3\envs\default\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\core\preprocessor.py:196: sample_distorted_bounding_box (from tensorflow.python.ops.image_ops_impl) is deprecated and will be removed in a future version. Instructions for updating: seed2 arg is deprecated.Use sample_distorted_bounding_box_v2 instead. WARNING:tensorflow:From C:\Users\qian\Anaconda3\envs\default\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\builders\dataset_builder.py:158: batch_and_drop_remainder (from tensorflow.contrib.data.python.ops.batching) is deprecated and will be removed in a future version. Instructions for updating: Use tf.data.Dataset.batch(..., drop_remainder=True). WARNING:tensorflow:From C:\Users\qian\Anaconda3\envs\default\lib\site-packages\tensorflow\python\ops\losses\losses_impl.py:448: to_float (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version. Instructions for updating: Use tf.cast instead. WARNING:tensorflow:From C:\Users\qian\Anaconda3\envs\default\lib\site-packages\tensorflow\python\ops\array_grad.py:425: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version. Instructions for updating: Use tf.cast instead. 2019-08-14 16:29:31.607841: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1433] Found device 0 with properties: name: GeForce GTX 1060 6GB major: 6 minor: 1 memoryClockRate(GHz): 1.7845 pciBusID: 0000:04:00.0 totalMemory: 6.00GiB freeMemory: 4.97GiB 2019-08-14 16:29:31.621836: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1512] Adding visible gpu devices: 0 2019-08-14 16:29:32.275712: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] Device interconnect StreamExecutor with strength 1 edge matrix: 2019-08-14 16:29:32.283072: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990] 0 2019-08-14 16:29:32.288675: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1003] 0: N 2019-08-14 16:29:32.293514: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 4714 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1060 6GB, pci bus id: 0000:04:00.0, compute capability: 6.1) WARNING:tensorflow:From C:\Users\qian\Anaconda3\envs\default\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\eval_util.py:796: to_int64 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version. Instructions for updating: Use tf.cast instead. WARNING:tensorflow:From C:\Users\qian\Anaconda3\envs\default\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\utils\visualization_utils.py:498: py_func (from tensorflow.python.ops.script_ops) is deprecated and will be removed in a future version. Instructions for updating: tf.py_func is deprecated in TF V2. Instead, use tf.py_function, which takes a python function which manipulates tf eager tensors instead of numpy arrays. It's easy to convert a tf eager tensor to an ndarray (just call tensor.numpy()) but having access to eager tensors means tf.py_functions can use accelerators such as GPUs as well as being differentiable using a gradient tape. 2019-08-14 16:41:44.736212: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1512] Adding visible gpu devices: 0 2019-08-14 16:41:44.741242: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] Device interconnect StreamExecutor with strength 1 edge matrix: 2019-08-14 16:41:44.747522: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990] 0 2019-08-14 16:41:44.751256: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1003] 0: N 2019-08-14 16:41:44.755548: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 4714 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1060 6GB, pci bus id: 0000:04:00.0, compute capability: 6.1) WARNING:tensorflow:From C:\Users\qian\Anaconda3\envs\default\lib\site-packages\tensorflow\python\training\saver.py:1266: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version. Instructions for updating: Use standard file APIs to check for files with this prefix. creating index... index created! creating index... index created! Running per image evaluation... Evaluate annotation type bbox DONE (t=2.43s). Accumulating evaluation results... DONE (t=0.14s). Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.287 Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.529 Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.278 Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000 Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.031 Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.312 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.162 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.356 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.356 Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000 Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.061 Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.384 (default) D:\gitcode\models\research>
QProgressBar 不动,多线程实现进度条
class ProcDlg : public QRunnable { public: ProcDlg(QProgressBar* progressBar); void run(); void setVal(int val); private: QProgressBar* m_ProgressBar; int m_val; }; ProcDlg::ProcDlg( QProgressBar* progressBar) { m_ProgressBar = progressBar; m_val = 0; } void ProcDlg::setVal(int val) { m_val = val; } void ProcDlg::run() { while (m_val <= 100) { QMetaObject::invokeMethod(m_ProgressBar, "setValue", Qt::QueuedConnection, Q_ARG(int, m_val)); QThread::sleep(1); if(m_val == 100) { break; } } } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private slots: void on_pushButton_clicked(); private: Ui::MainWindow *ui; QProgressBar procBar; ProcDlg* task; }; void MainWindow::on_pushButton_clicked() { task = new ProcDlg(&procBar); procBar.show(); QThreadPool::globalInstance()->start(task); int i = 1; for(i = 1; i <= 10; i++) { task->setVal(i*10); QThread::sleep(2); } } QProgressBar一直都不动,这是什么原因啊?
用openresty(nginx+lua)框架开发的项目实现接入统一认证功能,发请求拿token报xxxxx.com.cn could not be resolved (110: Operation timed out)
用openresty(nginx+lua)框架开发的项目实现接入统一认证功能(oauth2),发请求拿access-token时报xxxxx.com.cn could not be resolved (110: Operation timed out),同样的代码在centos,ubuntu虚拟机上测试时能成功运行并返回正确结果,把代码部署到centos服务器上就不行了 nginx部分配置如下 ``` resolver 114.114.114.114 8.8.8.8 8.8.4.4; include mime.types; server { listen 80; lua_ssl_verify_depth 10; lua_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt; set $resp_body ""; set $arg_accessToken ""; lua_need_request_body on; include location_aies.conf; } ``` oauth部分配置如下(在虚拟机中ip用localhost代替) ``` oauth_callback_url = 'http://10.xx.1xx.xx:80/oauth/callback' ``` 获得code后去拿access_token的代码如下 ``` local function request_access_token(code) --ngx.log(ngx.ERR, 'Requesting access token with code ' .. code) local httpc = http.new() httpc:set_timeout(7000) local payload = { client_id=client_id, grant_type="authorization_code", client_secret=client_secret, code=code } local params = { headers = { ["Content-Type"] = "application/x-www-form-urlencoded", }, method="POST",body=ngx.encode_args(payload) } local url=access_token_uri local res, err = httpc:request_uri(url, params) if err then **ngx.log(ngx.ERR, "Got error during access token request: " .. err)** ngx.header['Content-type'] = 'text/html' ngx.status = ngx.HTTP_FORBIDDEN ngx.say("Got error during access token request: " .. err) return ngx.exit(ngx.HTTP_FORBIDDEN) else ``` 就是这这段代码报错的,返回err,err信息为:Got error during access token request:xxxx.com.cn could not be resolved (110: Operation timed out) 我花了好久的时间都没解决,麻烦各路大神指点一下,谢谢了
关于 arm 指令 方法传参问题
请问这个方法一共有6个参数 fun1(int a1, int a2, int a3, int a4, int a5, int a6) 下面是方法体里面的具体arm指令: ``` .text:00001450 var_5C = -0x5C .text:00001450 var_58 = -0x58 .text:00001450 var_54 = -0x54 .text:00001450 var_50 = -0x50 .text:00001450 anonymous_1 = -0x4C .text:00001450 anonymous_3 = -0x48 .text:00001450 anonymous_5 = -0x44 .text:00001450 var_40 = -0x40 .text:00001450 var_30 = -0x30 .text:00001450 anonymous_0 = -0x2C .text:00001450 anonymous_2 = -0x28 .text:00001450 anonymous_4 = -0x24 .text:00001450 var_20 = -0x20 .text:00001450 arg_0 = 8 .text:00001450 arg_4 = 0xC .text:00001450 .text:00001450 ; __unwind { .text:00001450 PUSH {R4-R7,LR} .text:00001452 ADD R7, SP, #0xC .text:00001454 PUSH.W {R8-R11} .text:00001458 SUB SP, SP, #0x44 .text:0000145A MOV R11, R0 .text:0000145C LDR R0, =(__stack_chk_guard_ptr - 0x1466) .text:0000145E MOV R10, R3 .text:00001460 MOV R9, R2 .text:00001462 ADD R0, PC ; __stack_chk_guard_ptr .text:00001464 MOV R6, R1 .text:00001466 MOV.W R8, #0 .text:0000146A LDR R5, [R0] ; __stack_chk_guard .text:0000146C LDR R0, [R5] .text:0000146E STR R0, [SP,#0x60+var_20] .text:00001470 LSLS R0, R1, #0x1C .text:00001472 BNE loc_14F2 .text:00001474 ADD R4, SP, #0x60+var_50 .text:00001476 LDR R1, [R7,#arg_4] .text:00001478 MOVS R2, #0x10 .text:0000147A MOV R0, R4 ``` 我知道参数多于4个会放在栈中传递, 请问参数a6 是在哪里取出来的啊?
QT使用QMovie实现GIF动画播放,可是按钮全部没有用,无法播放。
mainwindow.cpp代码: #include "mainwindow.h" #include "ui_mainwindow.h" #include <QMovie> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; ui->label->setAlignment(Qt::AlignCenter); ui->label->setBackgroundRole(QPalette::Dark); ui->label->setAutoFillBackground(true); movie=new QMovie(this); movie->setFileName("../myMovie/3.gif"); movie->setCacheMode(QMovie::CacheAll); QSize size=ui->label->size(); movie->setScaledSize(size); ui->label->setMovie(movie); ui->label->show(); ui->horizontalSlider->setMinimum(0); ui->horizontalSlider->setMaximum(movie->frameCount()); connect(movie,SIGNAL(frameChanged(int)), ui->horizontalSlider,SLOT(setValue(int))); } void MainWindow::on_horizontalSlider_valueChanged(int value) { movie->jumpToFrame(value); } void MainWindow::on_pushButton_clicked() { movie->start(); } void MainWindow::on_pushButton_2_toggled(bool checked) { movie->setPaused(checked); } void MainWindow::on_pushButton_3_clicked() { movie->stop(); } void MainWindow::on_pushButton_4_clicked() { int id=movie->currentFrameNumber(); QPixmap pix=movie->currentPixmap(); pix.save(QString("../myMovie/%1.png").arg(id)); } void MainWindow::on_spinBox_valueChanged(int value) { movie->setSpeed(value); } mainwindow.h代码: #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMovie> #include <QMainWindow> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private slots: void on_horizontalSlider_valueChanged(int value); void on_pushButton_clicked(); void on_pushButton_2_toggled(bool checked); void on_pushButton_3_clicked(); void on_pushButton_4_clicked(); void on_spinBox_valueChanged(int arg1); private: Ui::MainWindow *ui; QMovie *movie; }; #endif // MAINWINDOW_H 出现错误: 1.点击开始按钮,没有反应。 2.点击暂停、停止、截屏、水平滑块等停止工作。 ![图片说明](https://img-ask.csdn.net/upload/201710/16/1508158022_466403.png) ![图片说明](https://img-ask.csdn.net/upload/201710/16/1508158033_117718.png) ![图片说明](https://img-ask.csdn.net/upload/201710/16/1508158044_49552.png)
ssm整合单元测试时候报错Failed to load ApplicationContext
报错代码如下 严重: Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@6108b2d7] to prepare test instance [com.atguigu.crud.test.MapperTest@49b0b76] java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124) at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:117) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83) at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.event.internalEventListenerProcessor': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0': Cannot resolve reference to bean 'txPoint' while setting bean property 'pointcut'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'txPoint': Failed to introspect bean class [org.springframework.aop.aspectj.AspectJExpressionPointcut] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:479) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:128) at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60) at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:108) at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:251) at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98) at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116) ... 25 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0': Cannot resolve reference to bean 'txPoint' while setting bean property 'pointcut'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'txPoint': Failed to introspect bean class [org.springframework.aop.aspectj.AspectJExpressionPointcut] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1531) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1276) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:92) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:102) at org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:103) at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessBeforeInstantiation(AbstractAutoProxyCreator.java:248) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:1037) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:1011) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:473) ... 38 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'txPoint': Failed to introspect bean class [org.springframework.aop.aspectj.AspectJExpressionPointcut] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:269) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1118) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1091) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:325) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351) ... 54 more Caused by: java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) at java.lang.Class.getDeclaredMethods(Class.java:1975) at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:613) at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:524) at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:510) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:247) ... 61 more Caused by: java.lang.ClassNotFoundException: org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWorldException at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 68 more 具体配置文件如下 applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd"> <!-- Spring 的配置文件 --> <context:component-scan base-package="com.atguigu"> <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" /> </context:component-scan> <!-- Spring的配置文件,这里主要配置和业务逻辑有关的 --> <!--=================== 数据源,事务控制,xxx ================--> <context:property-placeholder location="classpath:dbconfig.properties" /> <bean id="pooledDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="jdbcUrl" value="${jdbc.jdbcUrl}"></property> <property name="driverClass" value="${jdbc.driverClass}"></property> <property name="user" value="${jdbc.user}"></property> <property name="password" value="${jdbc.password}"></property> </bean> <!--================== 配置和MyBatis的整合=============== --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <!-- 指定mybatis全局配置文件的位置 --> <property name="configLocation" value="classpath:mybatis-config.xml"></property> <property name="dataSource" ref="pooledDataSource"></property> <!-- 指定mybatis,mapper文件的位置 --> <property name="mapperLocations" value="classpath:mapper/*.xml"></property> </bean> <!-- 配置扫描器,将mybatis接口的实现加入到ioc容器中 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <!--扫描所有dao接口的实现,加入到ioc容器中 --> <property name="basePackage" value="com.atguigu.crud.dao"></property> </bean> <!-- 配置一个可以执行批量的sqlSession --> <bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate"> <constructor-arg name="sqlSessionFactory" ref="sqlSessionFactory"></constructor-arg> <constructor-arg name="executorType" value="BATCH"></constructor-arg> </bean> <!--============================================= --> <!-- ===============事务控制的配置 ================--> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <!--控制住数据源 --> <property name="dataSource" ref="pooledDataSource"></property> </bean> <!--开启基于注解的事务,使用xml配置形式的事务(必要主要的都是使用配置式) --> <aop:config> <!-- 切入点表达式 --> <aop:pointcut expression="execution(* com.atguigu.crud.service..*(..))" id="txPoint"/> <!-- 配置事务增强 --> <aop:advisor advice-ref="txAdvice" pointcut-ref="txPoint"/> </aop:config> <!--配置事务增强,事务如何切入 --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <!-- 所有方法都是事务方法 --> <tx:method name="*"/> <!--以get开始的所有方法 --> <tx:method name="get*" read-only="true"/> </tx:attributes> </tx:advice> <!-- Spring配置文件的核心点(数据源、与mybatis的整合,事务控制) --> </beans> dispatcherServlet-servlet.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd"> <!--SpringMVC的配置文件,包含网站跳转逻辑的控制,配置 --> <context:component-scan base-package="com.atguigu" use-default-filters="false"> <!--只扫描控制器。 --> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/> </context:component-scan> <!--配置视图解析器,方便页面返回 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/"></property> <property name="suffix" value=".jsp"></property> </bean> <!--两个标准配置 --> <!-- 将springmvc不能处理的请求交给tomcat --> <mvc:default-servlet-handler/> <!-- 能支持springmvc更高级的一些功能,JSR303校验,快捷的ajax...映射动态请求 --> <mvc:annotation-driven/> </beans> mybatis-config.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration> <settings> <setting name="mapUnderscoreToCamelCase" value="true"/> </settings> <typeAliases> <package name="com.atguigu.crud.bean"/> </typeAliases> </configuration> MapperTest.java package com.atguigu.crud.test; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.atguigu.crud.dao.DepartmentMapper; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"classpath:applicationContext.xml"} ) public class MapperTest { @Autowired DepartmentMapper departmentMapper; @Test public void testCRUD() { /*ApplicationContext ioc = new ClassPathXmlApplicationContext("applicationContext.xml"); DepartmentMapper departmentMapper = ioc.getBean(DepartmentMapper.class);*/ System.out.println(departmentMapper); } } 求帮忙解决一下 困扰3天了,
小白使用keil编程debug进入了harddefault,搞了半天没解决。求大佬帮下忙。
/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file : main.c * @brief : Main program body ****************************************************************************** * @attention * * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics. * All rights reserved.</center></h2> * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "can.h" #include "usart.h" #include "gpio.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ void CAN_SetTxMsg(void) { hcan.pTxMsg->ExtId=0x1314; //使用的扩展ID hcan.pTxMsg->IDE=CAN_ID_EXT; //扩展模式 hcan.pTxMsg->RTR=CAN_RTR_DATA; //发送的是数据 hcan.pTxMsg->DLC=8; //数据长度为2字节 hcan.pTxMsg->data[0]=0x01; hcan.pTxMsg->data[1]=0x02; hcan.pTxMsg->data[2]=0x03; hcan.pTxMsg->data[3]=0x04; hcan.pTxMsg->data[4]=0x05; hcan.pTxMsg->data[5]=0x06; hcan.pTxMsg->data[6]=0x07; hcan.pTxMsg->data[7]=0x08; } /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN PTD */ /* USER CODE END PTD */ /* Private define ------------------------------------------------------------*/ /* USER CODE BEGIN PD */ /* USER CODE END PD */ /* Private macro -------------------------------------------------------------*/ /* USER CODE BEGIN PM */ /* USER CODE END PM */ /* Private variables ---------------------------------------------------------*/ /* USER CODE BEGIN PV */ /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); /* USER CODE BEGIN PFP */ /* USER CODE END PFP */ /* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ /** * @brief The application entry point. * @retval int */ int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration--------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_CAN_Init(); MX_USART1_UART_Init(); /* USER CODE BEGIN 2 */ CAN_SetTxMsg(); HAL_CAN_AddTxMessage(&hcan,hcan.pTxMsg,hcan.pTxMsg->data,(uint32_t*)CAN_TX_MAILBOX0); HAL_CAN_ActivateNotification(&hcan,CAN_IT_RX_FIFO0_MSG_PENDING); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ } /** * @brief System Clock Configuration * @retval None */ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; /** Initializes the CPU, AHB and APB busses clocks */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); } /** Initializes the CPU, AHB and APB busses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { Error_Handler(); } /** Enables the Clock Security System */ HAL_RCC_EnableCSS(); } /* USER CODE BEGIN 4 */ void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan) { HAL_CAN_AddTxMessage(hcan,hcan->pTxMsg,hcan->pTxMsg->data,(uint32_t*)CAN_TX_MAILBOX0); HAL_CAN_ActivateNotification(hcan,CAN_IT_RX_FIFO0_MSG_PENDING); } /* USER CODE END 4 */ /** * @brief This function is executed in case of error occurrence. * @retval None */ void Error_Handler(void) { /* USER CODE BEGIN Error_Handler_Debug */ /* User can add his own implementation to report the HAL error return state */ /* USER CODE END Error_Handler_Debug */ } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t *file, uint32_t line) { /* USER CODE BEGIN 6 */ /* User can add his own implementation to report the file name and line number, tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* USER CODE END 6 */ } #endif /* USE_FULL_ASSERT */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 这是我的主程序,debug总是在CAN_SetMsg()那里进入了hardfault.下面是定义的一些初始化结构体。 /** ****************************************************************************** * @file stm32f1xx_hal_can.h * @author MCD Application Team * @brief Header file of CAN HAL module. ****************************************************************************** * @attention * * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2> * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef STM32F1xx_HAL_CAN_H #define STM32F1xx_HAL_CAN_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32f1xx_hal_def.h" /** @addtogroup STM32F1xx_HAL_Driver * @{ */ #if defined (CAN1) /** @addtogroup CAN * @{ */ /* Exported types ------------------------------------------------------------*/ /** @defgroup CAN_Exported_Types CAN Exported Types * @{ */ /** * @brief HAL State structures definition */ typedef enum { HAL_CAN_STATE_RESET = 0x00U, /*!< CAN not yet initialized or disabled */ HAL_CAN_STATE_READY = 0x01U, /*!< CAN initialized and ready for use */ HAL_CAN_STATE_LISTENING = 0x02U, /*!< CAN receive process is ongoing */ HAL_CAN_STATE_SLEEP_PENDING = 0x03U, /*!< CAN sleep request is pending */ HAL_CAN_STATE_SLEEP_ACTIVE = 0x04U, /*!< CAN sleep mode is active */ HAL_CAN_STATE_ERROR = 0x05U /*!< CAN error state */ } HAL_CAN_StateTypeDef; /** * @brief CAN init structure definition */ typedef struct { uint32_t Prescaler; /*!< Specifies the length of a time quantum. This parameter must be a number between Min_Data = 1 and Max_Data = 1024. */ uint32_t Mode; /*!< Specifies the CAN operating mode. This parameter can be a value of @ref CAN_operating_mode */ uint32_t SyncJumpWidth; /*!< Specifies the maximum number of time quanta the CAN hardware is allowed to lengthen or shorten a bit to perform resynchronization. This parameter can be a value of @ref CAN_synchronisation_jump_width */ uint32_t TimeSeg1; /*!< Specifies the number of time quanta in Bit Segment 1. This parameter can be a value of @ref CAN_time_quantum_in_bit_segment_1 */ uint32_t TimeSeg2; /*!< Specifies the number of time quanta in Bit Segment 2. This parameter can be a value of @ref CAN_time_quantum_in_bit_segment_2 */ FunctionalState TimeTriggeredMode; /*!< Enable or disable the time triggered communication mode. This parameter can be set to ENABLE or DISABLE. */ FunctionalState AutoBusOff; /*!< Enable or disable the automatic bus-off management. This parameter can be set to ENABLE or DISABLE. */ FunctionalState AutoWakeUp; /*!< Enable or disable the automatic wake-up mode. This parameter can be set to ENABLE or DISABLE. */ FunctionalState AutoRetransmission; /*!< Enable or disable the non-automatic retransmission mode. This parameter can be set to ENABLE or DISABLE. */ FunctionalState ReceiveFifoLocked; /*!< Enable or disable the Receive FIFO Locked mode. This parameter can be set to ENABLE or DISABLE. */ FunctionalState TransmitFifoPriority;/*!< Enable or disable the transmit FIFO priority. This parameter can be set to ENABLE or DISABLE. */ } CAN_InitTypeDef; /** * @brief CAN filter configuration structure definition */ typedef struct { uint32_t FilterIdHigh; /*!< Specifies the filter identification number (MSBs for a 32-bit configuration, first one for a 16-bit configuration). This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */ uint32_t FilterIdLow; /*!< Specifies the filter identification number (LSBs for a 32-bit configuration, second one for a 16-bit configuration). This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */ uint32_t FilterMaskIdHigh; /*!< Specifies the filter mask number or identification number, according to the mode (MSBs for a 32-bit configuration, first one for a 16-bit configuration). This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */ uint32_t FilterMaskIdLow; /*!< Specifies the filter mask number or identification number, according to the mode (LSBs for a 32-bit configuration, second one for a 16-bit configuration). This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */ uint32_t FilterFIFOAssignment; /*!< Specifies the FIFO (0 or 1U) which will be assigned to the filter. This parameter can be a value of @ref CAN_filter_FIFO */ uint32_t FilterBank; /*!< Specifies the filter bank which will be initialized. For single CAN instance(14 dedicated filter banks), this parameter must be a number between Min_Data = 0 and Max_Data = 13. For dual CAN instances(28 filter banks shared), this parameter must be a number between Min_Data = 0 and Max_Data = 27. */ uint32_t FilterMode; /*!< Specifies the filter mode to be initialized. This parameter can be a value of @ref CAN_filter_mode */ uint32_t FilterScale; /*!< Specifies the filter scale. This parameter can be a value of @ref CAN_filter_scale */ uint32_t FilterActivation; /*!< Enable or disable the filter. This parameter can be a value of @ref CAN_filter_activation */ uint32_t SlaveStartFilterBank; /*!< Select the start filter bank for the slave CAN instance. For single CAN instances, this parameter is meaningless. For dual CAN instances, all filter banks with lower index are assigned to master CAN instance, whereas all filter banks with greater index are assigned to slave CAN instance. This parameter must be a number between Min_Data = 0 and Max_Data = 27. */ } CAN_FilterTypeDef; /** * @brief CAN Tx message header structure definition */ typedef struct { uint32_t StdId; /*!< Specifies the standard identifier. This parameter must be a number between Min_Data = 0 and Max_Data = 0x7FF. */ uint32_t ExtId; /*!< Specifies the extended identifier. This parameter must be a number between Min_Data = 0 and Max_Data = 0x1FFFFFFF. */ uint32_t IDE; /*!< Specifies the type of identifier for the message that will be transmitted. This parameter can be a value of @ref CAN_identifier_type */ uint32_t RTR; /*!< Specifies the type of frame for the message that will be transmitted. This parameter can be a value of @ref CAN_remote_transmission_request */ uint32_t DLC; /*!< Specifies the length of the frame that will be transmitted. This parameter must be a number between Min_Data = 0 and Max_Data = 8. */ uint8_t data[8]; FunctionalState TransmitGlobalTime; /*!< Specifies whether the timestamp counter value captured on start of frame transmission, is sent in DATA6 and DATA7 replacing pData[6] and pData[7]. @note: Time Triggered Communication Mode must be enabled. @note: DLC must be programmed as 8 bytes, in order these 2 bytes are sent. This parameter can be set to ENABLE or DISABLE. */ } CAN_TxHeaderTypeDef; /** * @brief CAN Rx message header structure definition */ typedef struct { uint32_t StdId; /*!< Specifies the standard identifier. This parameter must be a number between Min_Data = 0 and Max_Data = 0x7FF. */ uint32_t ExtId; /*!< Specifies the extended identifier. This parameter must be a number between Min_Data = 0 and Max_Data = 0x1FFFFFFF. */ uint32_t IDE; /*!< Specifies the type of identifier for the message that will be transmitted. This parameter can be a value of @ref CAN_identifier_type */ uint32_t RTR; /*!< Specifies the type of frame for the message that will be transmitted. This parameter can be a value of @ref CAN_remote_transmission_request */ uint32_t DLC; /*!< Specifies the length of the frame that will be transmitted. This parameter must be a number between Min_Data = 0 and Max_Data = 8. */ uint8_t Data[8]; uint32_t Timestamp; /*!< Specifies the timestamp counter value captured on start of frame reception. @note: Time Triggered Communication Mode must be enabled. This parameter must be a number between Min_Data = 0 and Max_Data = 0xFFFF. */ uint32_t FilterMatchIndex; /*!< Specifies the index of matching acceptance filter element. This parameter must be a number between Min_Data = 0 and Max_Data = 0xFF. */ } CAN_RxHeaderTypeDef; /** * @brief CAN handle Structure definition */ typedef struct __CAN_HandleTypeDef { CAN_TypeDef *Instance; /*!< Register base address */ CAN_InitTypeDef Init; /*!< CAN required parameters */ CAN_TxHeaderTypeDef* pTxMsg; CAN_RxHeaderTypeDef* pRxMsg; HAL_LockTypeDef Lock; __IO HAL_CAN_StateTypeDef State; /*!< CAN communication state */ __IO uint32_t ErrorCode; /*!< CAN Error code. This parameter can be a value of @ref CAN_Error_Code */ } CAN_HandleTypeDef; /** * @} */ /* Exported constants --------------------------------------------------------*/ /** @defgroup CAN_Exported_Constants CAN Exported Constants * @{ */ /** @defgroup CAN_Error_Code CAN Error Code * @{ */ #define HAL_CAN_ERROR_NONE (0x00000000U) /*!< No error */ #define HAL_CAN_ERROR_EWG (0x00000001U) /*!< Protocol Error Warning */ #define HAL_CAN_ERROR_EPV (0x00000002U) /*!< Error Passive */ #define HAL_CAN_ERROR_BOF (0x00000004U) /*!< Bus-off error */ #define HAL_CAN_ERROR_STF (0x00000008U) /*!< Stuff error */ #define HAL_CAN_ERROR_FOR (0x00000010U) /*!< Form error */ #define HAL_CAN_ERROR_ACK (0x00000020U) /*!< Acknowledgment error */ #define HAL_CAN_ERROR_BR (0x00000040U) /*!< Bit recessive error */ #define HAL_CAN_ERROR_BD (0x00000080U) /*!< Bit dominant error */ #define HAL_CAN_ERROR_CRC (0x00000100U) /*!< CRC error */ #define HAL_CAN_ERROR_RX_FOV0 (0x00000200U) /*!< Rx FIFO0 overrun error */ #define HAL_CAN_ERROR_RX_FOV1 (0x00000400U) /*!< Rx FIFO1 overrun error */ #define HAL_CAN_ERROR_TX_ALST0 (0x00000800U) /*!< TxMailbox 0 transmit failure due to arbitration lost */ #define HAL_CAN_ERROR_TX_TERR0 (0x00001000U) /*!< TxMailbox 1 transmit failure due to tranmit error */ #define HAL_CAN_ERROR_TX_ALST1 (0x00002000U) /*!< TxMailbox 0 transmit failure due to arbitration lost */ #define HAL_CAN_ERROR_TX_TERR1 (0x00004000U) /*!< TxMailbox 1 transmit failure due to tranmit error */ #define HAL_CAN_ERROR_TX_ALST2 (0x00008000U) /*!< TxMailbox 0 transmit failure due to arbitration lost */ #define HAL_CAN_ERROR_TX_TERR2 (0x00010000U) /*!< TxMailbox 1 transmit failure due to tranmit error */ #define HAL_CAN_ERROR_TIMEOUT (0x00020000U) /*!< Timeout error */ #define HAL_CAN_ERROR_NOT_INITIALIZED (0x00040000U) /*!< Peripheral not initialized */ #define HAL_CAN_ERROR_NOT_READY (0x00080000U) /*!< Peripheral not ready */ #define HAL_CAN_ERROR_NOT_STARTED (0x00100000U) /*!< Peripheral not started */ #define HAL_CAN_ERROR_PARAM (0x00200000U) /*!< Parameter error */ #define HAL_CAN_ERROR_INTERNAL (0x00800000U) /*!< Internal error */ /** * @} */ /** @defgroup CAN_InitStatus CAN InitStatus * @{ */ #define CAN_INITSTATUS_FAILED (0x00000000U) /*!< CAN initialization failed */ #define CAN_INITSTATUS_SUCCESS (0x00000001U) /*!< CAN initialization OK */ /** * @} */ /** @defgroup CAN_operating_mode CAN Operating Mode * @{ */ #define CAN_MODE_NORMAL (0x00000000U) /*!< Normal mode */ #define CAN_MODE_LOOPBACK ((uint32_t)CAN_BTR_LBKM) /*!< Loopback mode */ #define CAN_MODE_SILENT ((uint32_t)CAN_BTR_SILM) /*!< Silent mode */ #define CAN_MODE_SILENT_LOOPBACK ((uint32_t)(CAN_BTR_LBKM | CAN_BTR_SILM)) /*!< Loopback combined with silent mode */ /** * @} */ /** @defgroup CAN_synchronisation_jump_width CAN Synchronization Jump Width * @{ */ #define CAN_SJW_1TQ (0x00000000U) /*!< 1 time quantum */ #define CAN_SJW_2TQ ((uint32_t)CAN_BTR_SJW_0) /*!< 2 time quantum */ #define CAN_SJW_3TQ ((uint32_t)CAN_BTR_SJW_1) /*!< 3 time quantum */ #define CAN_SJW_4TQ ((uint32_t)CAN_BTR_SJW) /*!< 4 time quantum */ /** * @} */ /** @defgroup CAN_time_quantum_in_bit_segment_1 CAN Time Quantum in Bit Segment 1 * @{ */ #define CAN_BS1_1TQ (0x00000000U) /*!< 1 time quantum */ #define CAN_BS1_2TQ ((uint32_t)CAN_BTR_TS1_0) /*!< 2 time quantum */ #define CAN_BS1_3TQ ((uint32_t)CAN_BTR_TS1_1) /*!< 3 time quantum */ #define CAN_BS1_4TQ ((uint32_t)(CAN_BTR_TS1_1 | CAN_BTR_TS1_0)) /*!< 4 time quantum */ #define CAN_BS1_5TQ ((uint32_t)CAN_BTR_TS1_2) /*!< 5 time quantum */ #define CAN_BS1_6TQ ((uint32_t)(CAN_BTR_TS1_2 | CAN_BTR_TS1_0)) /*!< 6 time quantum */ #define CAN_BS1_7TQ ((uint32_t)(CAN_BTR_TS1_2 | CAN_BTR_TS1_1)) /*!< 7 time quantum */ #define CAN_BS1_8TQ ((uint32_t)(CAN_BTR_TS1_2 | CAN_BTR_TS1_1 | CAN_BTR_TS1_0)) /*!< 8 time quantum */ #define CAN_BS1_9TQ ((uint32_t)CAN_BTR_TS1_3) /*!< 9 time quantum */ #define CAN_BS1_10TQ ((uint32_t)(CAN_BTR_TS1_3 | CAN_BTR_TS1_0)) /*!< 10 time quantum */ #define CAN_BS1_11TQ ((uint32_t)(CAN_BTR_TS1_3 | CAN_BTR_TS1_1)) /*!< 11 time quantum */ #define CAN_BS1_12TQ ((uint32_t)(CAN_BTR_TS1_3 | CAN_BTR_TS1_1 | CAN_BTR_TS1_0)) /*!< 12 time quantum */ #define CAN_BS1_13TQ ((uint32_t)(CAN_BTR_TS1_3 | CAN_BTR_TS1_2)) /*!< 13 time quantum */ #define CAN_BS1_14TQ ((uint32_t)(CAN_BTR_TS1_3 | CAN_BTR_TS1_2 | CAN_BTR_TS1_0)) /*!< 14 time quantum */ #define CAN_BS1_15TQ ((uint32_t)(CAN_BTR_TS1_3 | CAN_BTR_TS1_2 | CAN_BTR_TS1_1)) /*!< 15 time quantum */ #define CAN_BS1_16TQ ((uint32_t)CAN_BTR_TS1) /*!< 16 time quantum */ /** * @} */ /** @defgroup CAN_time_quantum_in_bit_segment_2 CAN Time Quantum in Bit Segment 2 * @{ */ #define CAN_BS2_1TQ (0x00000000U) /*!< 1 time quantum */ #define CAN_BS2_2TQ ((uint32_t)CAN_BTR_TS2_0) /*!< 2 time quantum */ #define CAN_BS2_3TQ ((uint32_t)CAN_BTR_TS2_1) /*!< 3 time quantum */ #define CAN_BS2_4TQ ((uint32_t)(CAN_BTR_TS2_1 | CAN_BTR_TS2_0)) /*!< 4 time quantum */ #define CAN_BS2_5TQ ((uint32_t)CAN_BTR_TS2_2) /*!< 5 time quantum */ #define CAN_BS2_6TQ ((uint32_t)(CAN_BTR_TS2_2 | CAN_BTR_TS2_0)) /*!< 6 time quantum */ #define CAN_BS2_7TQ ((uint32_t)(CAN_BTR_TS2_2 | CAN_BTR_TS2_1)) /*!< 7 time quantum */ #define CAN_BS2_8TQ ((uint32_t)CAN_BTR_TS2) /*!< 8 time quantum */ /** * @} */ /** @defgroup CAN_filter_mode CAN Filter Mode * @{ */ #define CAN_FILTERMODE_IDMASK (0x00000000U) /*!< Identifier mask mode */ #define CAN_FILTERMODE_IDLIST (0x00000001U) /*!< Identifier list mode */ /** * @} */ /** @defgroup CAN_filter_scale CAN Filter Scale * @{ */ #define CAN_FILTERSCALE_16BIT (0x00000000U) /*!< Two 16-bit filters */ #define CAN_FILTERSCALE_32BIT (0x00000001U) /*!< One 32-bit filter */ /** * @} */ /** @defgroup CAN_filter_activation CAN Filter Activation * @{ */ #define CAN_FILTER_DISABLE (0x00000000U) /*!< Disable filter */ #define CAN_FILTER_ENABLE (0x00000001U) /*!< Enable filter */ /** * @} */ /** @defgroup CAN_filter_FIFO CAN Filter FIFO * @{ */ #define CAN_FILTER_FIFO0 (0x00000000U) /*!< Filter FIFO 0 assignment for filter x */ #define CAN_FILTER_FIFO1 (0x00000001U) /*!< Filter FIFO 1 assignment for filter x */ /** * @} */ /** @defgroup CAN_identifier_type CAN Identifier Type * @{ */ #define CAN_ID_STD ((uint32_t)0x00000000) /*!< Standard Id */ #define CAN_ID_EXT ((uint32_t)0x00000004) /*!< Extended Id */ /** * @} */ /** @defgroup CAN_remote_transmission_request CAN Remote Transmission Request * @{ */ #define CAN_RTR_DATA ((uint32_t)0x00000000) /*!< Data frame */ #define CAN_RTR_REMOTE ((uint32_t)0x00000002) /*!< Remote frame */ /** * @} */ /** @defgroup CAN_receive_FIFO_number CAN Receive FIFO Number * @{ */ #define CAN_RX_FIFO0 (0x00000000U) /*!< CAN receive FIFO 0 */ #define CAN_RX_FIFO1 (0x00000001U) /*!< CAN receive FIFO 1 */ /** * @} */ /** @defgroup CAN_Tx_Mailboxes CAN Tx Mailboxes * @{ */ #define CAN_TX_MAILBOX0 (0x00000001U) /*!< Tx Mailbox 0 */ #define CAN_TX_MAILBOX1 (0x00000002U) /*!< Tx Mailbox 1 */ #define CAN_TX_MAILBOX2 (0x00000004U) /*!< Tx Mailbox 2 */ /** * @} */ /** @defgroup CAN_flags CAN Flags * @{ */ /* Transmit Flags */ #define CAN_FLAG_RQCP0 (0x00000500U) /*!< Request complete MailBox 0 flag */ #define CAN_FLAG_TXOK0 (0x00000501U) /*!< Transmission OK MailBox 0 flag */ #define CAN_FLAG_ALST0 (0x00000502U) /*!< Arbitration Lost MailBox 0 flag */ #define CAN_FLAG_TERR0 (0x00000503U) /*!< Transmission error MailBox 0 flag */ #define CAN_FLAG_RQCP1 (0x00000508U) /*!< Request complete MailBox1 flag */ #define CAN_FLAG_TXOK1 (0x00000509U) /*!< Transmission OK MailBox 1 flag */ #define CAN_FLAG_ALST1 (0x0000050AU) /*!< Arbitration Lost MailBox 1 flag */ #define CAN_FLAG_TERR1 (0x0000050BU) /*!< Transmission error MailBox 1 flag */ #define CAN_FLAG_RQCP2 (0x00000510U) /*!< Request complete MailBox2 flag */ #define CAN_FLAG_TXOK2 (0x00000511U) /*!< Transmission OK MailBox 2 flag */ #define CAN_FLAG_ALST2 (0x00000512U) /*!< Arbitration Lost MailBox 2 flag */ #define CAN_FLAG_TERR2 (0x00000513U) /*!< Transmission error MailBox 2 flag */ #define CAN_FLAG_TME0 (0x0000051AU) /*!< Transmit mailbox 0 empty flag */ #define CAN_FLAG_TME1 (0x0000051BU) /*!< Transmit mailbox 1 empty flag */ #define CAN_FLAG_TME2 (0x0000051CU) /*!< Transmit mailbox 2 empty flag */ #define CAN_FLAG_LOW0 (0x0000051DU) /*!< Lowest priority mailbox 0 flag */ #define CAN_FLAG_LOW1 (0x0000051EU) /*!< Lowest priority mailbox 1 flag */ #define CAN_FLAG_LOW2 (0x0000051FU) /*!< Lowest priority mailbox 2 flag */ /* Receive Flags */ #define CAN_FLAG_FF0 (0x00000203U) /*!< RX FIFO 0 Full flag */ #define CAN_FLAG_FOV0 (0x00000204U) /*!< RX FIFO 0 Overrun flag */ #define CAN_FLAG_FF1 (0x00000403U) /*!< RX FIFO 1 Full flag */ #define CAN_FLAG_FOV1 (0x00000404U) /*!< RX FIFO 1 Overrun flag */ /* Operating Mode Flags */ #define CAN_FLAG_INAK (0x00000100U) /*!< Initialization acknowledge flag */ #define CAN_FLAG_SLAK (0x00000101U) /*!< Sleep acknowledge flag */ #define CAN_FLAG_ERRI (0x00000102U) /*!< Error flag */ #define CAN_FLAG_WKU (0x00000103U) /*!< Wake up interrupt flag */ #define CAN_FLAG_SLAKI (0x00000104U) /*!< Sleep acknowledge interrupt flag */ /* Error Flags */ #define CAN_FLAG_EWG (0x00000300U) /*!< Error warning flag */ #define CAN_FLAG_EPV (0x00000301U) /*!< Error passive flag */ #define CAN_FLAG_BOF (0x00000302U) /*!< Bus-Off flag */ /** * @} */ /** @defgroup CAN_Interrupts CAN Interrupts * @{ */ /* Transmit Interrupt */ #define CAN_IT_TX_MAILBOX_EMPTY ((uint32_t)CAN_IER_TMEIE) /*!< Transmit mailbox empty interrupt */ /* Receive Interrupts */ #define CAN_IT_RX_FIFO0_MSG_PENDING ((uint32_t)CAN_IER_FMPIE0) /*!< FIFO 0 message pending interrupt */ #define CAN_IT_RX_FIFO0_FULL ((uint32_t)CAN_IER_FFIE0) /*!< FIFO 0 full interrupt */ #define CAN_IT_RX_FIFO0_OVERRUN ((uint32_t)CAN_IER_FOVIE0) /*!< FIFO 0 overrun interrupt */ #define CAN_IT_RX_FIFO1_MSG_PENDING ((uint32_t)CAN_IER_FMPIE1) /*!< FIFO 1 message pending interrupt */ #define CAN_IT_RX_FIFO1_FULL ((uint32_t)CAN_IER_FFIE1) /*!< FIFO 1 full interrupt */ #define CAN_IT_RX_FIFO1_OVERRUN ((uint32_t)CAN_IER_FOVIE1) /*!< FIFO 1 overrun interrupt */ /* Operating Mode Interrupts */ #define CAN_IT_WAKEUP ((uint32_t)CAN_IER_WKUIE) /*!< Wake-up interrupt */ #define CAN_IT_SLEEP_ACK ((uint32_t)CAN_IER_SLKIE) /*!< Sleep acknowledge interrupt */ /* Error Interrupts */ #define CAN_IT_ERROR_WARNING ((uint32_t)CAN_IER_EWGIE) /*!< Error warning interrupt */ #define CAN_IT_ERROR_PASSIVE ((uint32_t)CAN_IER_EPVIE) /*!< Error passive interrupt */ #define CAN_IT_BUSOFF ((uint32_t)CAN_IER_BOFIE) /*!< Bus-off interrupt */ #define CAN_IT_LAST_ERROR_CODE ((uint32_t)CAN_IER_LECIE) /*!< Last error code interrupt */ #define CAN_IT_ERROR ((uint32_t)CAN_IER_ERRIE) /*!< Error Interrupt */ /** * @} */ /** * @} */ /* Exported macros -----------------------------------------------------------*/ /** @defgroup CAN_Exported_Macros CAN Exported Macros * @{ */ /** @brief Reset CAN handle state * @param __HANDLE__ CAN handle. * @retval None */ #define __HAL_CAN_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CAN_STATE_RESET) /** * @brief Enable the specified CAN interrupts. * @param __HANDLE__ CAN handle. * @param __INTERRUPT__ CAN Interrupt sources to enable. * This parameter can be any combination of @arg CAN_Interrupts * @retval None */ #define __HAL_CAN_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->IER) |= (__INTERRUPT__)) /** * @brief Disable the specified CAN interrupts. * @param __HANDLE__ CAN handle. * @param __INTERRUPT__ CAN Interrupt sources to disable. * This parameter can be any combination of @arg CAN_Interrupts * @retval None */ #define __HAL_CAN_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->IER) &= ~(__INTERRUPT__)) /** @brief Check if the specified CAN interrupt source is enabled or disabled. * @param __HANDLE__ specifies the CAN Handle. * @param __INTERRUPT__ specifies the CAN interrupt source to check. * This parameter can be a value of @arg CAN_Interrupts * @retval The state of __IT__ (TRUE or FALSE). */ #define __HAL_CAN_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->IER) & (__INTERRUPT__)) /** @brief Check whether the specified CAN flag is set or not. * @param __HANDLE__ specifies the CAN Handle. * @param __FLAG__ specifies the flag to check. * This parameter can be one of @arg CAN_flags * @retval The state of __FLAG__ (TRUE or FALSE). */ #define __HAL_CAN_GET_FLAG(__HANDLE__, __FLAG__) \ ((((__FLAG__) >> 8U) == 5U)? ((((__HANDLE__)->Instance->TSR) & (1U << ((__FLAG__) & CAN_FLAG_MASK))) == (1U << ((__FLAG__) & CAN_FLAG_MASK))): \ (((__FLAG__) >> 8U) == 2U)? ((((__HANDLE__)->Instance->RF0R) & (1U << ((__FLAG__) & CAN_FLAG_MASK))) == (1U << ((__FLAG__) & CAN_FLAG_MASK))): \ (((__FLAG__) >> 8U) == 4U)? ((((__HANDLE__)->Instance->RF1R) & (1U << ((__FLAG__) & CAN_FLAG_MASK))) == (1U << ((__FLAG__) & CAN_FLAG_MASK))): \ (((__FLAG__) >> 8U) == 1U)? ((((__HANDLE__)->Instance->MSR) & (1U << ((__FLAG__) & CAN_FLAG_MASK))) == (1U << ((__FLAG__) & CAN_FLAG_MASK))): \ (((__FLAG__) >> 8U) == 3U)? ((((__HANDLE__)->Instance->ESR) & (1U << ((__FLAG__) & CAN_FLAG_MASK))) == (1U << ((__FLAG__) & CAN_FLAG_MASK))): 0U) /** @brief Clear the specified CAN pending flag. * @param __HANDLE__ specifies the CAN Handle. * @param __FLAG__ specifies the flag to check. * This parameter can be one of the following values: * @arg CAN_FLAG_RQCP0: Request complete MailBox 0 Flag * @arg CAN_FLAG_TXOK0: Transmission OK MailBox 0 Flag * @arg CAN_FLAG_ALST0: Arbitration Lost MailBox 0 Flag * @arg CAN_FLAG_TERR0: Transmission error MailBox 0 Flag * @arg CAN_FLAG_RQCP1: Request complete MailBox 1 Flag * @arg CAN_FLAG_TXOK1: Transmission OK MailBox 1 Flag * @arg CAN_FLAG_ALST1: Arbitration Lost MailBox 1 Flag * @arg CAN_FLAG_TERR1: Transmission error MailBox 1 Flag * @arg CAN_FLAG_RQCP2: Request complete MailBox 2 Flag * @arg CAN_FLAG_TXOK2: Transmission OK MailBox 2 Flag * @arg CAN_FLAG_ALST2: Arbitration Lost MailBox 2 Flag * @arg CAN_FLAG_TERR2: Transmission error MailBox 2 Flag * @arg CAN_FLAG_FF0: RX FIFO 0 Full Flag * @arg CAN_FLAG_FOV0: RX FIFO 0 Overrun Flag * @arg CAN_FLAG_FF1: RX FIFO 1 Full Flag * @arg CAN_FLAG_FOV1: RX FIFO 1 Overrun Flag * @arg CAN_FLAG_WKUI: Wake up Interrupt Flag * @arg CAN_FLAG_SLAKI: Sleep acknowledge Interrupt Flag * @retval None */ #define __HAL_CAN_CLEAR_FLAG(__HANDLE__, __FLAG__) \ ((((__FLAG__) >> 8U) == 5U)? (((__HANDLE__)->Instance->TSR) = (1U << ((__FLAG__) & CAN_FLAG_MASK))): \ (((__FLAG__) >> 8U) == 2U)? (((__HANDLE__)->Instance->RF0R) = (1U << ((__FLAG__) & CAN_FLAG_MASK))): \ (((__FLAG__) >> 8U) == 4U)? (((__HANDLE__)->Instance->RF1R) = (1U << ((__FLAG__) & CAN_FLAG_MASK))): \ (((__FLAG__) >> 8U) == 1U)? (((__HANDLE__)->Instance->MSR) = (1U << ((__FLAG__) & CAN_FLAG_MASK))): 0U) /** * @} */ /* Exported functions --------------------------------------------------------*/ /** @addtogroup CAN_Exported_Functions CAN Exported Functions * @{ */ /** @addtogroup CAN_Exported_Functions_Group1 Initialization and de-initialization functions * @brief Initialization and Configuration functions * @{ */ /* Initialization and de-initialization functions *****************************/ HAL_StatusTypeDef HAL_CAN_Init(CAN_HandleTypeDef *hcan); HAL_StatusTypeDef HAL_CAN_DeInit(CAN_HandleTypeDef *hcan); void HAL_CAN_MspInit(CAN_HandleTypeDef *hcan); void HAL_CAN_MspDeInit(CAN_HandleTypeDef *hcan); /** * @} */ /** @addtogroup CAN_Exported_Functions_Group2 Configuration functions * @brief Configuration functions * @{ */ /* Configuration functions ****************************************************/ HAL_StatusTypeDef HAL_CAN_ConfigFilter(CAN_HandleTypeDef *hcan, CAN_FilterTypeDef *sFilterConfig); /** * @} */ /** @addtogroup CAN_Exported_Functions_Group3 Control functions * @brief Control functions * @{ */ /* Control functions **********************************************************/ HAL_StatusTypeDef HAL_CAN_Start(CAN_HandleTypeDef *hcan); HAL_StatusTypeDef HAL_CAN_Stop(CAN_HandleTypeDef *hcan); HAL_StatusTypeDef HAL_CAN_RequestSleep(CAN_HandleTypeDef *hcan); HAL_StatusTypeDef HAL_CAN_WakeUp(CAN_HandleTypeDef *hcan); uint32_t HAL_CAN_IsSleepActive(CAN_HandleTypeDef *hcan); HAL_StatusTypeDef HAL_CAN_AddTxMessage(CAN_HandleTypeDef *hcan, CAN_TxHeaderTypeDef *pHeader, uint8_t aData[], uint32_t *pTxMailbox); HAL_StatusTypeDef HAL_CAN_AbortTxRequest(CAN_HandleTypeDef *hcan, uint32_t TxMailboxes); uint32_t HAL_CAN_GetTxMailboxesFreeLevel(CAN_HandleTypeDef *hcan); uint32_t HAL_CAN_IsTxMessagePending(CAN_HandleTypeDef *hcan, uint32_t TxMailboxes); uint32_t HAL_CAN_GetTxTimestamp(CAN_HandleTypeDef *hcan, uint32_t TxMailbox); HAL_StatusTypeDef HAL_CAN_GetRxMessage(CAN_HandleTypeDef *hcan, uint32_t RxFifo, CAN_RxHeaderTypeDef *pHeader, uint8_t aData[]); uint32_t HAL_CAN_GetRxFifoFillLevel(CAN_HandleTypeDef *hcan, uint32_t RxFifo); /** * @} */ /** @addtogroup CAN_Exported_Functions_Group4 Interrupts management * @brief Interrupts management * @{ */ /* Interrupts management ******************************************************/ HAL_StatusTypeDef HAL_CAN_ActivateNotification(CAN_HandleTypeDef *hcan, uint32_t ActiveITs); HAL_StatusTypeDef HAL_CAN_DeactivateNotification(CAN_HandleTypeDef *hcan, uint32_t InactiveITs); void HAL_CAN_IRQHandler(CAN_HandleTypeDef *hcan); /** * @} */ /** @addtogroup CAN_Exported_Functions_Group5 Callback functions * @brief Callback functions * @{ */ /* Callbacks functions ********************************************************/ void HAL_CAN_TxMailbox0CompleteCallback(CAN_HandleTypeDef *hcan); void HAL_CAN_TxMailbox1CompleteCallback(CAN_HandleTypeDef *hcan); void HAL_CAN_TxMailbox2CompleteCallback(CAN_HandleTypeDef *hcan); void HAL_CAN_TxMailbox0AbortCallback(CAN_HandleTypeDef *hcan); void HAL_CAN_TxMailbox1AbortCallback(CAN_HandleTypeDef *hcan); void HAL_CAN_TxMailbox2AbortCallback(CAN_HandleTypeDef *hcan); void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan); void HAL_CAN_RxFifo0FullCallback(CAN_HandleTypeDef *hcan); void HAL_CAN_RxFifo1MsgPendingCallback(CAN_HandleTypeDef *hcan); void HAL_CAN_RxFifo1FullCallback(CAN_HandleTypeDef *hcan); void HAL_CAN_SleepCallback(CAN_HandleTypeDef *hcan); void HAL_CAN_WakeUpFromRxMsgCallback(CAN_HandleTypeDef *hcan); void HAL_CAN_ErrorCallback(CAN_HandleTypeDef *hcan); /** * @} */ /** @addtogroup CAN_Exported_Functions_Group6 Peripheral State and Error functions * @brief CAN Peripheral State functions * @{ */ /* Peripheral State and Error functions ***************************************/ HAL_CAN_StateTypeDef HAL_CAN_GetState(CAN_HandleTypeDef *hcan); uint32_t HAL_CAN_GetError(CAN_HandleTypeDef *hcan); HAL_StatusTypeDef HAL_CAN_ResetError(CAN_HandleTypeDef *hcan); /** * @} */ /** * @} */ /* Private types -------------------------------------------------------------*/ /** @defgroup CAN_Private_Types CAN Private Types * @{ */ /** * @} */ /* Private variables ---------------------------------------------------------*/ /** @defgroup CAN_Private_Variables CAN Private Variables * @{ */ /** * @} */ /* Private constants ---------------------------------------------------------*/ /** @defgroup CAN_Private_Constants CAN Private Constants * @{ */ #define CAN_FLAG_MASK (0x000000FFU) /** * @} */ /* Private Macros -----------------------------------------------------------*/ /** @defgroup CAN_Private_Macros CAN Private Macros * @{ */ #define IS_CAN_MODE(MODE) (((MODE) == CAN_MODE_NORMAL) || \ ((MODE) == CAN_MODE_LOOPBACK)|| \ ((MODE) == CAN_MODE_SILENT) || \ ((MODE) == CAN_MODE_SILENT_LOOPBACK)) #define IS_CAN_SJW(SJW) (((SJW) == CAN_SJW_1TQ) || ((SJW) == CAN_SJW_2TQ) || \ ((SJW) == CAN_SJW_3TQ) || ((SJW) == CAN_SJW_4TQ)) #define IS_CAN_BS1(BS1) (((BS1) == CAN_BS1_1TQ) || ((BS1) == CAN_BS1_2TQ) || \ ((BS1) == CAN_BS1_3TQ) || ((BS1) == CAN_BS1_4TQ) || \ ((BS1) == CAN_BS1_5TQ) || ((BS1) == CAN_BS1_6TQ) || \ ((BS1) == CAN_BS1_7TQ) || ((BS1) == CAN_BS1_8TQ) || \ ((BS1) == CAN_BS1_9TQ) || ((BS1) == CAN_BS1_10TQ)|| \ ((BS1) == CAN_BS1_11TQ)|| ((BS1) == CAN_BS1_12TQ)|| \ ((BS1) == CAN_BS1_13TQ)|| ((BS1) == CAN_BS1_14TQ)|| \ ((BS1) == CAN_BS1_15TQ)|| ((BS1) == CAN_BS1_16TQ)) #define IS_CAN_BS2(BS2) (((BS2) == CAN_BS2_1TQ) || ((BS2) == CAN_BS2_2TQ) || \ ((BS2) == CAN_BS2_3TQ) || ((BS2) == CAN_BS2_4TQ) || \ ((BS2) == CAN_BS2_5TQ) || ((BS2) == CAN_BS2_6TQ) || \ ((BS2) == CAN_BS2_7TQ) || ((BS2) == CAN_BS2_8TQ)) #define IS_CAN_PRESCALER(PRESCALER) (((PRESCALER) >= 1U) && ((PRESCALER) <= 1024U)) #define IS_CAN_FILTER_ID_HALFWORD(HALFWORD) ((HALFWORD) <= 0xFFFFU) #if defined(CAN2) #define IS_CAN_FILTER_BANK_DUAL(BANK) ((BANK) <= 27U) #endif #define IS_CAN_FILTER_BANK_SINGLE(BANK) ((BANK) <= 13U) #define IS_CAN_FILTER_MODE(MODE) (((MODE) == CAN_FILTERMODE_IDMASK) || \ ((MODE) == CAN_FILTERMODE_IDLIST)) #define IS_CAN_FILTER_SCALE(SCALE) (((SCALE) == CAN_FILTERSCALE_16BIT) || \ ((SCALE) == CAN_FILTERSCALE_32BIT)) #define IS_CAN_FILTER_ACTIVATION(ACTIVATION) (((ACTIVATION) == CAN_FILTER_DISABLE) || \ ((ACTIVATION) == CAN_FILTER_ENABLE)) #define IS_CAN_FILTER_FIFO(FIFO) (((FIFO) == CAN_FILTER_FIFO0) || \ ((FIFO) == CAN_FILTER_FIFO1)) #define IS_CAN_TX_MAILBOX(TRANSMITMAILBOX) (((TRANSMITMAILBOX) == CAN_TX_MAILBOX0 ) || \ ((TRANSMITMAILBOX) == CAN_TX_MAILBOX1 ) || \ ((TRANSMITMAILBOX) == CAN_TX_MAILBOX2 )) #define IS_CAN_TX_MAILBOX_LIST(TRANSMITMAILBOX) ((TRANSMITMAILBOX) <= (CAN_TX_MAILBOX0 | CAN_TX_MAILBOX1 | CAN_TX_MAILBOX2)) #define IS_CAN_STDID(STDID) ((STDID) <= 0x7FFU) #define IS_CAN_EXTID(EXTID) ((EXTID) <= 0x1FFFFFFFU) #define IS_CAN_DLC(DLC) ((DLC) <= 8U) #define IS_CAN_IDTYPE(IDTYPE) (((IDTYPE) == CAN_ID_STD) || \ ((IDTYPE) == CAN_ID_EXT)) #define IS_CAN_RTR(RTR) (((RTR) == CAN_RTR_DATA) || ((RTR) == CAN_RTR_REMOTE)) #define IS_CAN_RX_FIFO(FIFO) (((FIFO) == CAN_RX_FIFO0) || ((FIFO) == CAN_RX_FIFO1)) #define IS_CAN_IT(IT) ((IT) <= (CAN_IT_TX_MAILBOX_EMPTY | CAN_IT_RX_FIFO0_MSG_PENDING | \ CAN_IT_RX_FIFO0_FULL | CAN_IT_RX_FIFO0_OVERRUN | \ CAN_IT_RX_FIFO1_MSG_PENDING | CAN_IT_RX_FIFO1_FULL | \ CAN_IT_RX_FIFO1_OVERRUN | CAN_IT_WAKEUP | \ CAN_IT_SLEEP_ACK | CAN_IT_ERROR_WARNING | \ CAN_IT_ERROR_PASSIVE | CAN_IT_BUSOFF | \ CAN_IT_LAST_ERROR_CODE | CAN_IT_ERROR)) /** * @} */ /* End of private macros -----------------------------------------------------*/ /** * @} */ #endif /* CAN1 */ /** * @} */ #ifdef __cplusplus } #endif #endif /* STM32F1xx_HAL_CAN_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 求大佬指点哪里错了。。
Qt QMetaObject invokeMethod失败 如何查看失败原因?
调用 QMetaObject::invokeMethod(m_manager, "onEventRequest", Qt::QueuedConnection, Q_ARG(int, 0)); 没有执行onEventRequest函数,函数执行到这一句以后就卡在这里了, 由于m_manager是一个很大的类,整个流程就不贴上来了,现在怀疑m_manager跟onEventRequest的匹配上有问题, 请问如何查看invokeMethod执行失败的原因?
python 'if __name__ == "__main__":' 错误,直接执行测试(Terminal 运行正常)
main.py中的测试函数 import os.path as osp import pickle import model import weights import test def get_tf_implementation(weights_path, all_layer_outs=False): print("Making Structure") tf_model = model.make_deng_tf_test(verbose=True, all_layer_outs=all_layer_outs) print("Loading Weights") tf_model = weights.load_weights(tf_model, weights_path, verbose=True) return tf_model def get_test_data(cache_file): print("Loading Test Data") if osp.exists(cache_file): with open(cache_file, 'rb') as fid: roidb = pickle.load(fid) print('data is loaded from {}'.format(cache_file)) print(f"Number of Images to test: {len(roidb)}") return roidb def get_weighted_tf_implementation(weights_path, all_layer_outs=False): tf_model = get_tf_implementation(weights_path, all_layer_outs) model.show_model_info(tf_model) return tf_model def test_tf_implementation(cache_file, weights_path, all_layer_outs=False): # Get Weighted Model tf_model = get_weighted_tf_implementation(weights_path, all_layer_outs) # Load Cached Test Data roidb = get_test_data(cache_file) # Test Network results = test.test_net(tf_model, roidb) return results if __name__ == "__main__ 代码段: if __name__ == "__main__": results = test_tf_implementation(cache_file="roidb_test_19_smol.pkl", weights_path="rgbd_det_iter_40000.h5") Terminal运行一切正常,给cache-file和weights-path赋值,然后正常执行test_tf_implementation. 不知道问题出在哪里 错误提示: Using TensorFlow backend. EE ====================================================================== ERROR: main.get_test_data ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/xijiejiao/anaconda2/envs/python3/lib/python3.6/site-packages/nose/case.py", line 197, in runTest self.test(*self.arg) TypeError: get_test_data() missing 1 required positional argument: 'cache_file' -------------------- >> begin captured logging << -------------------- tensorflow: Level 1: Registering FakeQuantWithMinMaxArgs (<function _FakeQuantWithMinMaxArgsGradient at 0x1314c2598>) in gradient. tensorflow: Level 1: Registering FakeQuantWithMinMaxVars (<function _FakeQuantWithMinMaxVarsGradient at 0x1314c27b8>) in gradient. ``` ``` Error Traceback (most recent call last): File "/Users/xijiejiao/anaconda2/envs/python3/lib/python3.6/unittest/case.py", line 59, in testPartExecutor yield File "/Users/xijiejiao/anaconda2/envs/python3/lib/python3.6/unittest/case.py", line 605, in run testMethod() File "/Users/xijiejiao/anaconda2/envs/python3/lib/python3.6/site-packages/nose/case.py", line 197, in runTest self.test(*self.arg) Exception: get_test_data() missing 1 required positional argument: 'cache_file' -------------------- >> begin captured logging << -------------------- tensorflow: Level 1: Registering FakeQuantWithMinMaxArgs (<function _FakeQuantWithMinMaxArgsGradient at 0x1314c2598>) in gradient. tensorflow: Level 1: Registering FakeQuantWithMinMaxVars (<function _FakeQuantWithMinMaxVarsGradient at 0x1314c27b8>) in gradient. ``` ``` Error Traceback (most recent call last): File "/Users/xijiejiao/anaconda2/envs/python3/lib/python3.6/unittest/case.py", line 59, in testPartExecutor yield File "/Users/xijiejiao/anaconda2/envs/python3/lib/python3.6/unittest/case.py", line 605, in run testMethod() File "/Users/xijiejiao/anaconda2/envs/python3/lib/python3.6/site-packages/nose/case.py", line 197, in runTest self.test(*self.arg) TypeError: test_tf_implementation() missing 2 required positional arguments: 'cache_file' and 'weights_path' tensorflow: Level 1: Registering NcclAllReduce (<function _all_sum_grad at 0x131d62620>) in gradient. tensorflow: Level 1: Registering NcclReduce (<function _reduce_sum_grad at 0x131d628c8>) in gradient. tensorflow: Level 1: Registering NcclBroadcast (<function _broadcast_grad at 0x131d629d8>) in gradient. ``` ``` ====================================================================== ERROR: main.test_tf_implementation ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/xijiejiao/anaconda2/envs/python3/lib/python3.6/site-packages/nose/case.py", line 197, in runTest self.test(*self.arg) TypeError: test_tf_implementation() missing 2 required positional arguments: 'cache_file' and 'weights_path' ---------------------------------------------------------------------- Ran 2 tests in 0.020s FAILED (errors=2) Process finished with exit code 1 Assertion failed Assertion failed Assertion failed Assertion failed
QPixmap加载BMP图片,内存溢出,怎么办?
初始化后两个label可以显示图片,当点击按钮切换两个label显示图片后,求报错:QImage: out of memory, returning null image。我的每张图片都是6512*11635的BMP图片,大小为72.2M,我觉得是加载的缓存区不够大导致的,需要每次显示需要清理缓存区,不知道对不对,经过调试,问题就是在点击按钮后出发的函数里面的load加载图片。我用QPixmapCache::clear()也没有用,该肿么办?求大神指点 void MinImage::loadMinImage() //初始化 { i = 1; QDir dir("/image1","*.bmp"); if(!dir.exists()) return; dir.setSorting(QDir::Time);//文件排列方式:时间 background1.load(QString("E:/image1/%1").arg(dir[dir.count()-i])); background1 = background1.scaled(background1.width(),background1.height(),Qt::KeepAspectRatio); label_image1->setPixmap(background1); i++; background2.load(QString("E:/image1/%1").arg(dir[dir.count()-i])); background2 = background2.scaled(background2.width(),background2.height(),Qt::KeepAspectRatio); label_image2->setPixmap(background2); } void MinImage::Right_Button_clicked() { QDir dir("/image1","*.bmp"); dir.setSorting(QDir::Time); if(i==dir.count()) { QMessageBox::warning(this,"warning","Has reached the final!"); } else { i++; background1.load(QString("E:/image1/%1").arg(dir[dir.count()-i+1])); background1 = background1.scaled(background1.width(),background1.height(),Qt::KeepAspectRatio); label_image1->setPixmap(background1); background2.load(QString("E:/image1/%1").arg(dir[dir.count()-i])); background2 = background2.scaled(background2.width(),background2.height(),Qt::KeepAspectRatio); label_image2->setPixmap(background2); } } void MinImage::Left_Button_clicked() { QDir dir("/image1","*.bmp"); dir.setSorting(QDir::Time); if(i==2) { QMessageBox::warning(this,"warning","Has reached the final!"); } else { i--; background1.load(QString("E:/image1/%1").arg(dir[dir.count()-i+1])); background1 = background1.scaled(background1.width(),background1.height(),Qt::KeepAspectRatio); label_image1->setPixmap(background1); background2.load(QString("E:/image1/%1").arg(dir[dir.count()-i])); background2 = background2.scaled(background2.width(),background2.height(),Qt::KeepAspectRatio); label_image2->setPixmap(background2); qDebug()<<i; } }
QT代码,里面调用了一些Ubuntu命令,不是很明白其用途
``` void Widget::on_pushButton_clicked(){ QDateTime current_date_time = QDateTime::currentDateTime(); QString targz, cmd_find, cmd_tar; if(ui->radioButton->isChecked()){ cmd_find = "find ./ -type f | grep -v \'Permission denied\' > TEPLIST";// 将没有permisson denied的文件列出 targz = current_date_time.toString("yyyy-MM-dd_hh.mm.ss") + ".full.tar.gz"; }else{ int minDiff = get_min(current_date_time); // 获得是最小的查值 cmd_find = QString("find ./ -mmin -%1 -type f | grep -v \'Permission denied\' > TEPLIST").arg(minDiff);//?????? targz = current_date_time.toString("yyyy-MM-dd_hh.mm.ss") + ".inc.tar.gz"; } /* * 将上面重构后的命令进行执行-> 查找可压缩文件 */ QStringList cmd_pipe;// 初始化了一个String目录 cmd_pipe << "-c" << cmd_find; // ???????? cmd->start("/bin/bash",cmd_pipe); // 开始一个程序 cmd->waitForFinished(); cmd->close(); cmd_tar = QString("tar --verbose --totals --exclude-vcs %1 --files-from=TEPLIST -czf %2/%3").arg(exclude_from).arg(dir_dest).arg(targz);// cout << cmd_tar.data(); runCommand(cmd_tar); QString err = QString::fromLocal8Bit(cmd->readAllStandardError()); if(err.isEmpty()) outputInfo("Backup Suceess!"); runCommand("rm TEPLIST"); /*********** Encrypting*************/ // gpg-k 增加公共钥匙 if(ui->checkBox->isChecked()){ QString cmd_isKey = "gpg -k " + gpg_key;//添加公钥 runCommand(cmd_isKey); QString cmd_enc; QString out = QString::fromLocal8Bit(cmd->readAllStandardOutput());// ?????? if(out.isEmpty()) // -o, --output FILE write output to FILE // c 说是使用对称加密,看起来很奇怪 /* * 我用你的公钥来加密我要发给你的数据,在你收到加密数据后用你的私钥解密就可以拿到原始数据。 * 我用我的私钥“加密”一段公开的数据,你用我的公钥可以验证这段公开数据是否是我发出的。 * */ cmd_enc = QString("gpg -c -o %1/%2.gpg %1/%2").arg(dir_dest).arg(targz);// ???? else // e 是加密数据 , 针对 用户 id 进行加密 cmd_enc = QString("gpg -e -r %1 -o %2/%3.gpg %2/%3").arg(gpg_key).arg(dir_dest).arg(targz);//?????? runCommand(cmd_enc); if(false == ui->checkBox_2->isChecked()){ runCommand(QString("rm %1/%2.gpg").arg(dir_dest).arg(targz)); } if(false == ui->checkBox_3->isChecked()){ runCommand( QString("rm %1/%2").arg(dir_dest).arg(targz)); } } backupInfo(); } 1. ``` 上面这串代码有几个小问题: 在 ``` cmd_find = "find ./ -type f | grep -v \'Permission denied\' > TEPLIST";// 将没有permisson denied的文件列出 ``` 和 ``` cmd_find = QString("find ./ -mmin -%1 -type f | grep -v \'Permission denied\' > TEPLIST").arg(minDiff);//????? ``` 这里面都有这个\'Permission denied\', 我对grep v的理解是把我find里面 找出的来的文件中,不符合上面这个字符串的文件都给排除掉,但是这个似乎只能排除掉文件名是含有的字符串,但是很明显,这个猜测是错的,我不知道这个字符串的意义是什么 2. 还是上面这个,这个 -mmin是什么意思呢,他用getmin获取了最新时间和上次时间的差值,然后再把这个minDiff放进去,这是为了啥? 3. 还是上面这个, ``` cmd_pipe << "-c" << cmd_find; ``` 他在上面这个 生成的linux后面用了这个玩意儿,不知道是为啥 4. ``` cmd_tar = QString("tar --verbose --totals --exclude-vcs %1 --files-from=TEPLIST -czf %2/%3").arg(exclude_from).arg(dir_dest).arg(targz); ``` 我对这句话的理解是进行除了exclude文件里面的一些后缀之外都进行压缩,但是这个exclude后面的-vcs 是干嘛的? 5. ``` cmd_enc = QString("gpg -c -o %1/%2.gpg %1/%2").arg(dir_dest).arg(targz);// ???? else // e 是加密数据 , 针对 用户 id 进行加密 cmd_enc = QString("gpg -e -r %1 -o %2/%3.gpg %2/%3").arg(gpg_key).arg(dir_dest).arg(targz);//?????? runCommand(cmd_enc); ``` 上面是对 文件进行两种加密,这两种加密的区别是啥? 6. 前面加一个 gpg -k 密码 是不是,直接就是生成了公钥,后面不用加文件名字吗?
qt 运行出来的框图有残缺
# cpp文件 ``` #include "vsbak.h" #include "ui_vsbak.h" #include <QSettings> #include <QFileDialog> #include<QTime> #include<QtDebug> #include <QMessageBox> #define CONFIG_FILE "config.ini" const QString EXCLUDE_FILE = "/home/hu/project2";// 這個文件沒啥用 Vsbak::Vsbak(QWidget *parent) : QWidget(parent) , ui(new Ui::Vsbak) { ui->setupUi(this); QSettings *configIniRead = new QSettings(CONFIG_FILE, QSettings::IniFormat); dir_src = configIniRead->value("/main/bak_src").toString(); dir_dest = configIniRead->value("/main/bak_dest").toString(); // 配置文件里面有目标地址 gpg_key = configIniRead->value("/main/gpg_key").toString(); exclude_from = configIniRead->value("exclude/exclude").toString(); delete configIniRead; // init bash terminal //QProcess可以用于启动外部程序 cmd = new QProcess(this);// 因为与父类直接释放内存 // Sets the working directory to dir. QProcess will start the process in this directory. //The default behavior is to start the process in the working directory of the calling process. cmd->setWorkingDirectory(dir_src); //This signal is emitted when the process has made new data available //through its standard output channel (stdout). It is emitted regardless of the current read channel. connect(cmd, &QProcess::readyReadStandardOutput, this, &Vsbak::on_readyReadStandardOutput); connect(cmd, &QProcess::readyReadStandardError, this, &Vsbak::on_readyReadStandardError); ui->lineEdit->setText(dir_src); ui->lineEdit_2->setText(dir_dest); // 在ui里直接设置这个地址 // init comboBox init_comboBox(); // init radiobutton: choice full ui->radioButton->setChecked(true); ui->checkBox->setChecked(false); ui->checkBox_2->setEnabled(false); ui->checkBox_3->setEnabled(false); } /* * 设置最大可见数目为5,是不是不合理? */ void Vsbak::init_comboBox() // 找压缩好的文件 Combobox 下拉菜单 { /* * 1. 用一个对象进入dir-dest目录下 * 2. 过滤掉包含后追的文件 * 3. 获取被过滤的文件理解 */ // find all backup.tar.gz files //The QDir class provides access to directory structures and their contents. 不仅能看到结构,还可以看到目录 QDir *curDir = new QDir(dir_dest); //The QStringList class provides a list of strings. //可以让你提取一个新的列表只包含这些字符串包含一个特定的字符串(或匹配特定正则表达式) QStringList filter; // 过渡成一个目录 filter << "*.tar.gz" << "*.tar.gz.gpg"; curDir->setNameFilters(filter); // 过滤掉特定的目录下的文件 //Returns a list of QFileInfo objects for all the files and directories in the directory //QDir::entryInfoList()会获取该目录下所有目录和文件的QFileInfo对象的列表 QList<QFileInfo> *tarFileInfo = new QList<QFileInfo>(curDir->entryInfoList(filter)); /* * dir_dest 里面存放的其实都是被压缩的文件,所以用上面的后缀直接进行过滤 * 1. 设置最大的可见数目为5 * 2. 看目录里面有多少,然后放入这个comboBox * 3. 获取被过滤的文件 * 4. 按照顺序放入到combobox中 */ ui->comboBox->clear(); ui->comboBox->setMaxVisibleItems(5); // 最大可见数目 5 //The string will be inserted as the first item in the combobox. ui->comboBox->setInsertPolicy(QComboBox::InsertAtTop); for (int i=0; i< tarFileInfo->count(); i++)// count()只是计算里面的数量,tarFileinfo实际上是一个文件列表 ui->comboBox->addItem(tarFileInfo->at(i).fileName()); } Vsbak::~Vsbak() { delete ui; // 有何作用 if(cmd->state() == QProcess::Running){ cmd->terminate(); cmd->waitForFinished(); } } void Vsbak::on_readyReadStandardOutput() { // QString out = QString::fromLocal8Bit(cmd->readAllStandardOutput()); // ui->label_4->setText(out); } void Vsbak::on_readyReadStandardError() { QMessageBox::information(0, "Error", cmd->readAllStandardError()); } // change dir_src void Vsbak::on_toolButton_clicked() { /* * 1. 或许dir_src的文件目录名称 * 2. 将dir_src的文件目录名写到lineEdit上面 * 3. 更新配置文件里面的信息 * 4. 设置工作目录 * */ QString dirname; dirname = QFileDialog::getExistingDirectory(this, tr("Open Directory"), dir_src, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); if(dirname.isEmpty()) return; else { dir_src = dirname; ui->lineEdit->setText(dir_src); QSettings *configIniWrite = new QSettings(CONFIG_FILE, QSettings::IniFormat); configIniWrite->setValue("/main/bak_src", dir_src); delete configIniWrite; cmd->setWorkingDirectory(dir_src); ui->label_4->setText("change source dir sucess!"); } } // change dir_dest void Vsbak::on_toolButton_2_clicked() { QString dirname; // getExistingDirectory 只获取文件夹 dirname = QFileDialog::getExistingDirectory(this, tr("Open Directory"), dir_dest, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); if(dirname.isEmpty()) return; else { dir_dest = dirname; ui->lineEdit_2->setText(dir_dest); QSettings *configIniWrite = new QSettings(CONFIG_FILE, QSettings::IniFormat); configIniWrite->setValue("/main/bak_dest", dir_dest); delete configIniWrite; ui->label_4->setText("change dest dir sucess!"); } } int Vsbak::get_min(QDateTime curTime) { QSettings *configIniReadWrite = new QSettings(CONFIG_FILE, QSettings::IniFormat); int lastTime = configIniReadWrite->value("/main/last_time").toInt();// 将值转化成整形 configIniReadWrite->setValue("/main/last_time", curTime.toTime_t()); delete configIniReadWrite; int minDiff = (curTime.toTime_t()-lastTime) / 60 + 1; return minDiff; } void Vsbak::on_checkBox_clicked() { if(ui->checkBox->isChecked()){ ui->checkBox_2->setEnabled(true); ui->checkBox_3->setEnabled(true); } else{ ui->checkBox_2->setEnabled(false); ui->checkBox_3->setEnabled(false); } } /* * 3 个 String类型 * targz:time + full.tar.gz * cmd_find:find ./ -type f | grep -v \'Permission denied\' > TEPLIST * cmd_tar *目录列表 * * * */ void Vsbak::on_pushButton_clicked(){ // The QDateTime class provides date and time functions. // 调用QDatetime里面的一个函数,赋给另一个QDatetime的类型 QDateTime current_date_time = QDateTime::currentDateTime(); // 初始化三个String类型 QString targz, cmd_find, cmd_tar; //RadioButton presents an option button that can be toggled on (checked) or off (unchecked). //Radio buttons are typically used to select one option from a set of options. //Use isChecked() to see if a particular button is selected. if(ui->radioButton->isChecked()){ // 如果radiobutton 被选择了,那么就进行备份,如果没有就只输出时间 // Linux find命令用来在指定目录下查找文件。 // 将目前目录其其下子目录中所有一般文件列出 # find . -type f // Linux grep 命令用于查找文件里符合条件的字符串。 // -v 或 --revert-match : 显示不包含匹配文本的所有行。 // 反向查找。前面各个例子是查找并打印出符合条件的行,通过"-v"参数可以打印出不符合条件行的内容。 // ./ 表示当前目录的全路径 当前目录的全路径 没有这个 \'Permission denied\'???? //linux的命令,查找文件然后设置权限 // 这个是不管修改不修改,全部列出来 cmd_find = "find ./ -type f | grep -v \'Permission denied\' > TEPLIST";// 这个功能是什么呢 targz = current_date_time.toString("yyyy-MM-dd_hh.mm.ss") + ".full.tar.gz"; }else{ // 会替换掉前面的百分之1,替换规则是从小到大 //get_min是一个函数,看它具体怎么实现的,应该是循环遍历了current_date_time,找到最小???? int minDiff = get_min(current_date_time); // 获得是最小的查值 // 完成命令,把距离最新一次全部修改的文件单独列出来 cmd_find = QString("find ./ -mmin -%1 -type f | grep -v \'Permission denied\' > TEPLIST").arg(minDiff); targz = current_date_time.toString("yyyy-MM-dd_hh.mm.ss") + ".inc.tar.gz"; } // exclude from 是一个配置目录 // tar命令 //-v或--verbose 显示指令执行过程 // --totals 备份文件建立后,列出文件大小 //cmd_tar这是压缩tar的linux命令,将exclude里面的文件全部列出来,进行压缩 cmd_tar = QString("tar --verbose --totals --exclude-vcs %1 --files-from=TEPLIST -czf %2/%3").arg(exclude_from).arg(dir_dest).arg(targz);//?5 // 向调试器输出命令的执行结果,方便调试排错 qDebug()<< cmd_find << endl << cmd_tar<< endl; // 下面整个过程就是执行这个命令 QStringList cmd_pipe;// 初始化了一个String目录 cmd_pipe << "-c" << cmd_find; // 说明这个cmd-pipe已经变成了一个linux的cmd命令了 cmd->start("/bin/bash",cmd_pipe); // 开始一个程序 cmd->waitForFinished(); cmd->close(); cmd->start(cmd_tar);// cmd_tar 也变成了一个程序 cmd->waitForFinished(); cmd->close(); cmd->start("rm -f TEPLIST");// 强制删除teplist, teplist 就是临时文件 cmd->waitForFinished(); /*********** Encrypting*************/ // gpg-k 增加公共钥匙 if(ui->checkBox->isChecked()){ QString cmd_enc; QString cmd_isKey = "gpg -k " + gpg_key; cmd->start(cmd_isKey); cmd->waitForFinished(); QString out = QString::fromLocal8Bit(cmd->readAllStandardOutput());// 这个输出就不是很理解为什么 if(out.isEmpty()) // -o, --output FILE write output to FILE // c 说是使用对称加密,看起来很奇怪 cmd_enc = QString("gpg -c -o %1/%2.gpg %1/%2").arg(dir_dest).arg(targz); else // e 是加密数据 , 针对 用户 id 进行加密 cmd_enc = QString("gpg -e -r %1 -o %2/%3.gpg %2/%3").arg(gpg_key).arg(dir_dest).arg(targz); cmd->start(cmd_enc); cmd->waitForFinished(); if(false == ui->checkBox_2->isChecked()){ QString cmd_rm = QString("rm %1/%2.gpg").arg(dir_dest).arg(targz); cmd->start(cmd_rm); cmd->waitForFinished(); } if(false == ui->checkBox_3->isChecked()){ QString cmd_rm = QString("rm %1/%2").arg(dir_dest).arg(targz); cmd->start(cmd_rm); cmd->waitForFinished(); } /* * /home/hu/桌面/vsbak/backup/2019-11-13_19.38.57.full.tar.gz * */ // ui->comboBox->addItem(targz); init_comboBox(); } } void Vsbak::on_pushButton_2_clicked(){ QString targz = ui->comboBox->currentText(); if (targz.endsWith(".tar.gz.gpg")){ targz = targz.remove(".gpg"); QString cmd_enc; QString cmd_isKey = "gpg -k " + gpg_key; cmd->start(cmd_isKey); cmd->waitForFinished(); QString out = QString::fromLocal8Bit(cmd->readAllStandardOutput()); if(out.isEmpty()) cmd_enc = QString("gpg -d -o %1/%2 %1/%2.gpg").arg(dir_dest).arg(targz); else cmd_enc = QString("gpg -d -r %1 -o %2/%3 %2/%3.gpg").arg(gpg_key).arg(dir_dest).arg(targz); cmd->start(cmd_enc); cmd->waitForFinished(); } QString cmd_str = QString("tar -xvf %1/%2").arg(dir_dest).arg(targz); qDebug() << cmd_str; cmd->start(cmd_str); cmd->waitForFinished(); } ``` 上面是cpp文件 下面是 # h文件 #ifndef VSBAK_H #define VSBAK_H #include <QWidget> #include<QProcess> QT_BEGIN_NAMESPACE namespace Ui { class Vsbak; } QT_END_NAMESPACE class Vsbak : public QWidget { Q_OBJECT public: Vsbak(QWidget *parent = nullptr); ~Vsbak(); private slots: void on_readyReadStandardOutput(); void on_readyReadStandardError(); void on_toolButton_clicked(); void on_toolButton_2_clicked(); void on_pushButton_clicked(); void on_pushButton_2_clicked(); void on_checkBox_clicked(); private: Ui::Vsbak *ui; QProcess *cmd; QString dir_dest; QString dir_src; QString gpg_key; QString exclude_from; void init_comboBox(); int get_min(QDateTime curTime);// 获得整形 }; #endif // VSBAK_H 我运行之后出来的qt界面,原本是可以下拉选择的,但是都没有反映,这是为啥
QT调试代码出现提示信息错误
QT调试代码中出现 Internal error: pc 0xa0520000 in read in psymtab, but not in symtab. 请问下这是问题,怎么解决?对程序有影响吗? 下面是我的代码 #include "socketwidget.h" #include <QPushButton> #include <QTextEdit> #include <QLineEdit> #include <QLabel> #include <QDebug> #include <QHostAddress> #include <QByteArray> SocketWidget::SocketWidget(QWidget *parent) : QWidget(parent) { send_btn = new QPushButton(this); send_btn->setText("send"); send_btn->setGeometry(9,268,78,23); close_btn = new QPushButton(this); close_btn->setText("close"); close_btn->setGeometry(316,268,75,23); connect_btn = new QPushButton(this); connect_btn->setText("connect"); connect_btn->setGeometry(316,20,75,23); connect(send_btn,&QPushButton::clicked,this,&SocketWidget::on_buttonSend_clicked); connect(close_btn,&QPushButton::clicked,this,&SocketWidget::on_buttonClose_clicked); connect(connect_btn,&QPushButton::clicked,this,&SocketWidget::on_buttonConnect_clicked); send_btn->setEnabled(false); close_btn->setEnabled(false); label1 = new QLabel(this); label1->setText("服务器IP:"); label1->setGeometry(9,9,72,20); label2 = new QLabel(this); label2->setText("服务器端口:"); label2->setGeometry(9,35,72,20); lineEditIP = new QLineEdit(this); lineEditIP->setText("127.0.0.1"); lineEditIP->setGeometry(87,9,223,20); lineEditPort = new QLineEdit(this); lineEditPort->setText("8888"); lineEditPort->setGeometry(87,35,223,20); textEditRead = new QTextEdit(this); textEditRead->setReadOnly(true); textEditRead->setGeometry(9,61,382,97); textEditWrite = new QTextEdit(this); textEditWrite->setGeometry(9,164,382,98); tcpSocket =NULL; //分配空间制定父对象 tcpSocket = new QTcpSocket(this); setWindowTitle("客户端"); connect(tcpSocket,&QTcpSocket::connected, [=]() { textEditRead->setText("成功和服务器连接"); send_btn->setEnabled(true); close_btn->setEnabled(true); connect_btn->setEnabled(false); } ); connect(tcpSocket,&QTcpSocket::readyRead,this,&SocketWidget::onSocketReadyRead); connect(tcpSocket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error), this, &SocketWidget::displayError); } SocketWidget::~SocketWidget() { } void SocketWidget::onSocketReadyRead() { if(tcpSocket->bytesAvailable() <= 0) { return; } qint64 totalBytes = 0; m_buffer = NULL; //从缓存区去除数据,但是不确定取出来的字节数; QByteArray buffer= tcpSocket->readAll(); m_buffer.append(buffer); unsigned int totalLen = m_buffer.size(); textEditRead->append(buffer); //这边确实需要利用长度做while循环,因为有可能一下子读取到两条以上的完整记录,就需要进行循环处理了; //超过一条完整小于第二条完整记录时,如果已经达到包头长度就先把包头保存下来,整个过程循环往复 while (totalLen) { //与QDataStream绑定,方便操作 QDataStream packet(m_buffer); packet.setVersion(QDataStream::Qt_5_10); //不够包头长度的不处理,结束while循环 unsigned int MINSIZE = sizeof(qint64)*2; if(totalLen < MINSIZE) { //textEditRead->append(buffer); break; } //将包头读入了进来按照定义的协议,先读命令长度,再读命令的类型; packet >> totalBytes >>serverCmd; //缓存中的内容长度没有达到命令的长度,那就先结束,等足够了再来解析 if(totalLen<totalBytes) break; //足够长了就开始解析 // QDir dir(sysFilePath); //系统文件目录 // if(!dir.exists()) // dir.mkdir(sysFilePath); switch (serverCmd) { case QString_recv: { qDebug()<<"开始接收字符串..."; QByteArray datas = m_buffer.mid(MINSIZE,totalBytes-MINSIZE); QString strInfo;//数据包中的message strInfo.prepend(datas); qDebug() <<strInfo;//输出接收到的QString } break; default: //qint64 nbytes = tcpSocket->bytesAvailable(); //textEditRead->append(buffer); break; } //缓存多余的数据 buffer = m_buffer.right(totalLen - totalBytes); //截取下一个数据包的数据,留作下次读取 totalLen = buffer.size(); //更新多余的数据 m_buffer = buffer; } /* while (tcpSocket->bytesAvailable() > 0) { qint64 nbytes = tcpSocket->bytesAvailable(); QByteArray array = tcpSocket->read(nbytes); textEditRead->append(array); }*/ } void SocketWidget::on_buttonConnect_clicked() { QHostAddress localIP = QHostAddress("127.0.0.1"); //获取服务器ip和端口 QString ip = lineEditIP->text(); qint16 port = lineEditPort->text().toInt(); //tcpSocket->abort(); if(tcpSocket->bind(localIP,42055) ) { qDebug() << "1 localHost:" << localIP.toString(); qDebug() << "2 localPort:" << tcpSocket->localPort(); } tcpSocket->abort(); //主动和服务器建立连接 tcpSocket->connectToHost(ip, port); if(tcpSocket->waitForConnected(1000) ) { send_btn->setEnabled(true); close_btn->setEnabled(true); connect_btn->setEnabled(false); } else { QMessageBox::information(this, tr(" Client"), tr("连接失败,请检查后重试")); } } void SocketWidget::on_buttonSend_clicked() { //获取编辑框内容 QString str = textEditWrite->toPlainText(); //发送数据 tcpSocket->write(str.toUtf8().data() ); if(tcpSocket->waitForBytesWritten(1000) ) { textEditWrite->clear(); } else { QMessageBox::information(this, tr(" Client"), tr("内容为空,输入后从新发送")); } } void SocketWidget::displayError(QAbstractSocket::SocketError socketError) { switch (socketError) { case QAbstractSocket::RemoteHostClosedError: connect_btn->setEnabled(true); send_btn->setEnabled(false); close_btn->setEnabled(false); QMessageBox::information(this, tr(" Client"), tr("The host was disconnect. Please check and " "request again.")); textEditRead->append("服务器已断开连接"); break; case QAbstractSocket::HostNotFoundError: QMessageBox::information(this, tr(" Client"), tr("The host was not found. Please check the " "host name and port settings.")); break; case QAbstractSocket::ConnectionRefusedError: QMessageBox::information(this, tr(" Client"), tr("The connection was refused by the peer. " "Make sure the server is running, " "and check that the host name and port " "settings are correct.")); break; default: QMessageBox::information(this, tr(" Client"), tr("The following error occurred: %1.") .arg(tcpSocket->errorString())); } } void SocketWidget::on_buttonClose_clicked() { //主动和对方断开连接 tcpSocket->disconnectFromHost(); if(tcpSocket->state() == QAbstractSocket::UnconnectedState || tcpSocket->waitForDisconnected(1000) ) { tcpSocket->close(); connect_btn->setEnabled(true); send_btn->setEnabled(false); close_btn->setEnabled(false); textEditRead->append("已断开连接"); } else { QMessageBox::information(this, tr(" Client"), tr("断开连接失败,请检查后重试")); } }
相见恨晚的超实用网站
相见恨晚的超实用网站 持续更新中。。。
字节跳动视频编解码面经
三四月份投了字节跳动的实习(图形图像岗位),然后hr打电话过来问了一下会不会opengl,c++,shador,当时只会一点c++,其他两个都不会,也就直接被拒了。 七月初内推了字节跳动的提前批,因为内推没有具体的岗位,hr又打电话问要不要考虑一下图形图像岗,我说实习投过这个岗位不合适,不会opengl和shador,然后hr就说秋招更看重基础。我当时想着能进去就不错了,管他哪个岗呢,就同意了面试...
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它是一个过程,是一个不断累积、不断沉淀、不断总结、善于传达自己的个人见解以及乐于分享的过程。
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过...
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 free -m 其中:m表示兆,也可以用g,注意都要小写 Men:表示物理内存统计 total:表示物理内存总数(total=used+free) use...
比特币原理详解
一、什么是比特币 比特币是一种电子货币,是一种基于密码学的货币,在2008年11月1日由中本聪发表比特币白皮书,文中提出了一种去中心化的电子记账系统,我们平时的电子现金是银行来记账,因为银行的背后是国家信用。去中心化电子记账系统是参与者共同记账。比特币可以防止主权危机、信用风险。其好处不多做赘述,这一层面介绍的文章很多,本文主要从更深层的技术原理角度进行介绍。 二、问题引入 假设现有4个人...
python学习方法总结(内附python全套学习资料)
不要再问我python好不好学了 我之前做过半年少儿编程老师,一个小学四年级的小孩子都能在我的教学下独立完成python游戏,植物大战僵尸简单版,如果要肯花时间,接下来的网络开发也不是问题,人工智能也可以学个调包也没啥问题。。。。。所以python真的是想学就一定能学会的!!!! --------------------华丽的分割线-------------------------------- ...
python 简易微信实现(注册登录+数据库存储+聊天+GUI+文件传输)
socket+tkinter详解+简易微信实现 历经多天的努力,查阅了许多大佬的博客后终于实现了一个简易的微信O(∩_∩)O~~ 简易数据库的实现 使用pands+CSV实现数据库框架搭建 import socket import threading from pandas import * import pymysql import csv # 创建DataFrame对象 # 存储用户数据的表(...
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发...
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 演示地点演示 html代码如下` music 这个年纪 七月的风 音乐 ` 然后就是css`*{ margin: 0; padding: 0; text-decoration: none; list-...
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。
数据库优化 - SQL优化
以实际SQL入手,带你一步一步走上SQL优化之路!
2019年11月中国大陆编程语言排行榜
2019年11月2日,我统计了某招聘网站,获得有效程序员招聘数据9万条。针对招聘信息,提取编程语言关键字,并统计如下: 编程语言比例 rank pl_ percentage 1 java 33.62% 2 cpp 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7 p...
通俗易懂地给女朋友讲:线程池的内部原理
餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”
《奇巧淫技》系列-python!!每天早上八点自动发送天气预报邮件到QQ邮箱
将代码部署服务器,每日早上定时获取到天气数据,并发送到邮箱。 也可以说是一个小型人工智障。 知识可以运用在不同地方,不一定非是天气预报。
经典算法(5)杨辉三角
杨辉三角 是经典算法,这篇博客对它的算法思想进行了讲解,并有完整的代码实现。
Python实例大全(基于Python3.7.4)
博客说明: 这是自己写的有关python语言的一篇综合博客。 只作为知识广度和编程技巧学习,不过于追究学习深度,点到即止、会用即可。 主要是基础语句,如三大控制语句(顺序、分支、循环),随机数的生成,数据类型的区分和使用; 也会涉及常用的算法和数据结构,以及面试题相关经验; 主体部分是针对python的数据挖掘和数据分析,主要先攻爬虫方向:正则表达式匹配,常用数据清洗办法,scrapy及其他爬虫框架,数据存储方式及其实现; 最后还会粗略涉及人工智能领域,玩转大数据与云计算、进行相关的预测和分析。
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹...
面试官:你连RESTful都不知道我怎么敢要你?
干货,2019 RESTful最贱实践
刷了几千道算法题,这些我私藏的刷题网站都在这里了!
遥想当年,机缘巧合入了 ACM 的坑,周边巨擘林立,从此过上了"天天被虐似死狗"的生活… 然而我是谁,我可是死狗中的战斗鸡,智力不够那刷题来凑,开始了夜以继日哼哧哼哧刷题的日子,从此"读题与提交齐飞, AC 与 WA 一色 ",我惊喜的发现被题虐既刺激又有快感,那一刻我泪流满面。这么好的事儿作为一个正直的人绝不能自己独享,经过激烈的颅内斗争,我决定把我私藏的十几个 T 的,阿不,十几个刷题网...
为啥国人偏爱Mybatis,而老外喜欢Hibernate/JPA呢?
关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论,感触还是有一些,于是就有了今天这篇文。 声明:本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实,讲道理,所以,请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题,争论已经很多年了。一直也没有结论,毕竟每个人的喜好和习惯是大不相同的。我也看...
SQL-小白最佳入门sql查询一
不要偷偷的查询我的个人资料,即使你再喜欢我,也不要这样,真的不好;
JavaScript 为什么能活到现在?
作者 | 司徒正美 责编 |郭芮 出品 | CSDN(ID:CSDNnews) JavaScript能发展到现在的程度已经经历不少的坎坷,早产带来的某些缺陷是永久性的,因此浏览器才有禁用JavaScript的选项。甚至在jQuery时代有人问出这样的问题,jQuery与JavaScript哪个快?在Babel.js出来之前,发明一门全新的语言代码代替JavaScript...
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // doshom...
Nginx 原理和架构
Nginx 是一个免费的,开源的,高性能的 HTTP 服务器和反向代理,以及 IMAP / POP3 代理服务器。Nginx 以其高性能,稳定性,丰富的功能,简单的配置和低资源消耗而闻名。 Nginx 的整体架构 Nginx 里有一个 master 进程和多个 worker 进程。master 进程并不处理网络请求,主要负责调度工作进程:加载配置、启动工作进程及非停升级。worker 进程负责处...
致 Python 初学者
欢迎来到“Python进阶”专栏!来到这里的每一位同学,应该大致上学习了很多 Python 的基础知识,正在努力成长的过程中。在此期间,一定遇到了很多的困惑,对未来的学习方向感到迷茫。我非常理解你们所面临的处境。我从2007年开始接触 python 这门编程语言,从2009年开始单一使用 python 应对所有的开发工作,直至今天。回顾自己的学习过程,也曾经遇到过无数的困难,也曾经迷茫过、困惑过。开办这个专栏,正是为了帮助像我当年一样困惑的 Python 初学者走出困境、快速成长。希望我的经验能真正帮到你
Python 编程开发 实用经验和技巧
Python是一门很灵活的语言,也有很多实用的方法,有时候实现一个功能可以用多种方法实现,我这里总结了一些常用的方法和技巧,包括小数保留指定位小数、判断变量的数据类型、类方法@classmethod、制表符中文对齐、遍历字典、datetime.timedelta的使用等,会持续更新......
吐血推荐珍藏的Visual Studio Code插件
作为一名Java工程师,由于工作需要,最近一个月一直在写NodeJS,这种经历可以说是一部辛酸史了。好在有神器Visual Studio Code陪伴,让我的这段经历没有更加困难。眼看这段经历要告一段落了,今天就来给大家分享一下我常用的一些VSC的插件。 VSC的插件安装方法很简单,只需要点击左侧最下方的插件栏选项,然后就可以搜索你想要的插件了。 下面我们进入正题 Material Theme ...
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,...
相关热词 c#中dns类 c#合并的excel c# implicit c#怎么保留3个小数点 c# 串口通信、 网络调试助手c# c# 泛型比较大小 c#解压分卷问题 c#启动居中 c# 逻辑或运算符
立即提问

相似问题

1
深度学习图片识别循环停止?
1
activemq报错:Transport scheme NOT recognized: [tcp]
1
安卓开发中,我在Spinner的onItemSelected函数里访问全局变量程序就会CrashHandler闪退
0
KERNEL_SECURITY_CHECK_FAILURE
2
用TensorFlow 训练mask rcnn时,总是在执行训练语句时报错,进行不下去了,求大神
0
小白求问为什么应用一进去就闪退了
4
python 'if __name__ == "__main__":' 错误,直接执行测试(Terminal 运行正常)
2
QT调试代码出现提示信息错误
1
小白使用keil编程debug进入了harddefault,搞了半天没解决。求大佬帮下忙。
3
编译Linux程序出现“对‘pthread_create’未定义的引用”。
1
在训练Tensorflow模型(object_detection)时,训练在第一次评估后退出,怎么使训练继续下去?
1
在arm上利用Qt采集视频图像,能够保存采集的视频图像
3
现在是一些关键操作要记录操作日志,但是在insert的时候,偶然会出现插入失败的问题.现在找不到问题所在?
0
信号量一小段学习代码,看不懂输出,求教
1
tensorflow.python.framework.errors_impl.InvalidArgumentError
1
Python混合执行函数参数
1
STM32F103CBT6上移植ucos操作系统 仿真后LED任务不运行一直处于空闲任务 是什么原因啊?
2
安卓对话框中显示Toast问题
2
STM32F103CBT6上移植ucos操作系统 仿真后LED任务不运行一直处于空闲任务 是什么原因啊?
1
最近windowsServer2008服务器总是报错重启,有没有大神能帮忙分析下dmp文件?