VSPE虚拟串口关机蓝屏(BSOD)的解决办法

记一次VSPE蓝屏问题的解决

本文仅仅是针对我遇到的这次蓝屏问题的解决,并不是所有人都会遇到由这种操作导致的蓝屏,也不是VSPE就有这个蓝屏问题。

  • VSPE(Virtual Serial Ports Emulator Version 0.938 (June 26, 2010))

蓝屏复现

启动VSPE模拟串口,启动后最小化不关闭该软件。关闭计算机,关机到最后会出现蓝屏。且不生成蓝屏dump文件,怀疑生成dump的程序都已经在蓝屏出现前被关闭了。

蓝屏原因

经过检测是关机的时候没有正常关闭VSPE软件导致VSPE还在后台模拟串口(不停读取真实串口数据)导致。

解决办法

  1. 利用VSPE提供的API编写注销工具并将该工具放在VSPE程序的根目录下
  2. 编写脚本,脚本用来在Windows注销时结束VSPE程序及调用自己写的注销工具
  3. 在Windows 注销时调用脚本

代码

注销工具 VSPEmulator.exe 源码

// 
// 用于在强制结束VPSE软件后停止所有模拟串口设备
// 将该代码编译后生成的exe放置于VSPE根目录下
//

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>

// include VSPE API header and library
#include "VSPE_API.h"
#pragma comment(lib,"VSPE_API.lib")

int main()
{
    // ****************************
    // STEP 1 - INITIALIZATION
    // ****************************
    // 添加KEY
    // 32位系统下的KEY免费, 在SetupVSPE.zip压缩包内的VSPE_API_32_KEY.txt文件中
    const char* activationKey = ""; 
    bool result;

    // activate VSPE API
    result = vspe_activate(activationKey);
    if(result == false){
        printf("VSPE API activation error");
        return 1;
    }

    // initialize VSPE python binding subsystem
    result = vspe_initialize();
    if(result == false){
        printf("Initialization error");
        return 1;
    }

    int count = vspe_getDevicesCount();
    printf("Devices count: %d\n", count);

    // remove all existing devices
    vspe_destroyAllDevices();

    // stop current emulation
    result = vspe_stopEmulation();
    if(result == false)
    {
        printf("Error: emulation can not be stopped: maybe one of VSPE devices is still used.");
        vspe_release();
        return 1;
    }

    vspe_release();

    printf("Destroy success.\n");
    return 0;
}

将编译后的VSPEmulator.exe拷贝至VPSE根目录下。

KillVspe.bat脚本

taskkill /f /im VSPEmulator.exe

cd /d "C:\Program Files\Eterlogic.com\Virtual Serial Ports Emulator\"
ping 127.0.0.1 -n 3 >nul

VSPE_Destroy.exe

将KillVspe.bat脚本添加到Windows注销组策略(gpedit.msc)中,让Windows关闭时调用此脚本。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值