绘制基础,hang的由来分析

2019-10-04 作者:美高梅4688am   |   浏览(61)

得到道具条件的新闻

1. 问题

实践求证:

星期三, 05. 九月 2018 02:03上午 - beautifulzzzz

原因:未启用TLS1.0

美高梅4688am 1美高梅4688am 2

当在console中调用API ShellExecuteEx展开"test.iqy"文件时,发现excel会hang住,console退出后excel才会响应,但间接双击"test.iqy"是尚未难题的,有趣的是那些情景唯有在xp产生,在win7上尚无这么些难点。

 入门Linux,平常会遇见以下多少个难题:

  • 从什么地方获得LInux镜像?
  • 哪些通过镜像文件安装Linux系统?
  • 设置实体机照旧虚构机?
  • 设置完系统怎样安排互联网?
  • 设想机的网络布局与实体机有什么分歧?

 那本章大家针对  网络联网起始化  扩充详细的讲课


美高梅4688am 3

 

  1 //DEVCAPS1.C--Device Capabilities Display Program No.1 (c) Charles Petzold, 1998
  2 #include <Windows.h>
  3 
  4 #define NUMLINES ((int) (sizeof(devcaps) / sizeof(devcaps[0])))
  5 struct  
  6 {
  7     int iIndex;
  8     TCHAR *szLabel;
  9     TCHAR *szDesc;
 10 }
 11 devcaps[] =
 12 {
 13     HORZSIZE,        TEXT("HORZSIZE"),        TEXT("Width in millimeters:"),
 14     VERTSIZE,        TEXT("VERTSIZE"),        TEXT("Height in milimeters:"),
 15     HORZRES,        TEXT("HORZRES"),        TEXT("Width in pixels:"),
 16     VERTRES,        TEXT("VERTRES"),        TEXT("Height in raster lines:"),
 17     BITSPIXEL,        TEXT("BITSPIXEL"),        TEXT("Color bits per pixel:"),
 18     PLANES,            TEXT("PLANES"),            TEXT("Number of color planes:"),
 19     NUMBRUSHES,        TEXT("NUMBRUSHES"),        TEXT("Number of device brushes"),
 20     NUMPENS,        TEXT("NUMPENS"),        TEXT("Number of device pens:"),
 21     NUMMARKERS,        TEXT("NUMMARKERS"),        TEXT("Number of device markers:"),
 22     NUMFONTS,        TEXT("NUMFONTS"),        TEXT("Number of device fonts:"),
 23     NUMCOLORS,        TEXT("NUMCOLORS"),        TEXT("Number of device colors:"),
 24     PDEVICESIZE,    TEXT("PDEVICESIZE"),    TEXT("Size of device structure:"),
 25     ASPECTX,        TEXT("ASPECTX"),        TEXT("Relative width of pixel:"),
 26     ASPECTY,        TEXT("ASPECTY"),        TEXT("Relative height of pixel:"),
 27     ASPECTXY,        TEXT("ASPECTXY"),        TEXT("Relative diagonal of pixel:"),
 28     LOGPIXELSX,        TEXT("LOGPIXELSX"),        TEXT("Horizontal dots per inch:"),
 29     LOGPIXELSY,        TEXT("LOGPIXELSY"),        TEXT("Vertical dots per inch:"),
 30     SIZEPALETTE,    TEXT("SIZEPALETTE"),    TEXT("Number of palette entries:"),
 31     NUMRESERVED,    TEXT("NUMRESERVED"),    TEXT("Reserved palette entries:"),
 32     COLORRES,        TEXT("COLORRES"),        TEXT("Actual color resolution:")
 33 };
 34 
 35 LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
 36 
 37 int WINAPI WinMain( __in HINSTANCE hInstance
 38                     , __in_opt HINSTANCE hPrevInstance
 39                     , __in LPSTR lpCmdLine
 40                     , __in int nShowCmd )
 41 {
 42     static TCHAR szAppName[] = TEXT("DevCaps1");
 43     HWND hwnd;
 44     MSG msg;
 45     WNDCLASS wndclass;
 46 
 47     wndclass.style = CS_HREDRAW | CS_VREDRAW;
 48     wndclass.lpfnWndProc = WndProc;
 49     wndclass.cbClsExtra = 0;
 50     wndclass.cbWndExtra = 0;
 51     wndclass.hInstance = hInstance;
 52     wndclass.hIcon= LoadIcon(NULL, IDI_APPLICATION);
 53     wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
 54     wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
 55     wndclass.lpszMenuName = NULL;
 56     wndclass.lpszClassName = szAppName;
 57 
 58     if (!RegisterClass(&wndclass))
 59     {
 60         MessageBox(NULL, TEXT("This program requires Window NT!")
 61             , szAppName, MB_ICONERROR);
 62         return 0;
 63     }
 64 
 65     hwnd = CreateWindow(szAppName, TEXT("Device Capabilities")
 66         , WS_OVERLAPPEDWINDOW
 67         , CW_USEDEFAULT, CW_USEDEFAULT
 68         , CW_USEDEFAULT, CW_USEDEFAULT
 69         , NULL, NULL, hInstance, NULL);
 70 
 71     ShowWindow(hwnd, nShowCmd);
 72     UpdateWindow(hwnd);
 73 
 74     while (GetMessage(&msg, NULL, 0, 0))
 75     {
 76         TranslateMessage(&msg);
 77         DispatchMessage(&msg);
 78     }
 79 
 80     return msg.wParam;
 81 }
 82 
 83 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 84 {
 85     static int cxChar, cxCaps, cyChar;
 86     TCHAR szBuffer[10];
 87     HDC hdc;
 88     int i;
 89     PAINTSTRUCT ps;
 90     TEXTMETRIC tm;
 91 
 92     switch (message)
 93     {
 94     case WM_CREATE:
 95         hdc = GetDC(hwnd);
 96         GetTextMetrics(hdc, &tm);
 97         cxChar = tm.tmAveCharWidth;
 98         cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar / 2;
 99         cyChar = tm.tmHeight + tm.tmExternalLeading;
100         ReleaseDC(hwnd, hdc);
101         return 0;
102 
103     case WM_PAINT:
104         hdc = BeginPaint(hwnd, &ps);
105         for (i = 0; i != NUMLINES; ++i)
106         {
107             TextOut(hdc, 0, cyChar * i, devcaps[i].szLabel
108                 , lstrlen(devcaps[i].szLabel));
109             TextOut(hdc, 14 * cxCaps, cyChar * i, devcaps[i].szDesc
110                 , lstrlen(devcaps[i].szDesc));
111             SetTextAlign(hdc, TA_RIGHT | TA_TOP);
112             TextOut(hdc, 14 * cxCaps + 35 * cxChar, cyChar * i, szBuffer
113                 , wsprintf(szBuffer, TEXT("%5d"), GetDeviceCaps(hdc, devcaps[i].iIndex)));
114             SetTextAlign(hdc, TA_LEFT | TA_TOP);
115         }
116         EndPaint(hwnd, &ps);
117         return 0;
118 
119     case WM_DESTROY:
120         PostQuitMessage(0);
121         return 0;
122     }
123 
124     return DefWindowProc(hwnd, message, wParam, lParam);
125 }

 

实验遭逢:

  • 宿主机系统  :Window 10 1803
  • VMware版本 :VMware Workstation Pro 14
  • 设想机配置  :系统:CentOS 7.2 1511
                网络:NET模式(VMnet8) 192.168.18.0

1、前言

上一篇讲了哪些编译安装BlueZ-5,本篇首要在于玩BlueZ,用命令行去操作BLE设备:

  • [BlueZ] 1、Download install and use the BlueZ and hcitool on PI 3B+

美高梅4688am 4

缓慢解决格局:

DEVCAPS1.C

2. 复出步骤

尝试步骤:

2、gatttool —— 老工具趟坑

刚开首接着 Get Started with Bluetooth Low Energy on Linux 操作gatttool,开掘坑太多(重要缘由是工具老了):

采用sudo gatttool -b 4D:69:98:0E:91:5E -I去连接
意识会报错:Error: connect error: Connection refused (111)
最后参照他事他说加以考察LINK-11开掘需求加random选项([#1](https://stackoverflow.com/questions/32947807/cannot-connect-to-ble-device-on-raspberry-pi))

➜  ~  sudo gatttool -b 4D:69:98:0E:91:5E -I
[4D:69:98:0E:91:5E][LE]> connect
Attempting to connect to 4D:69:98:0E:91:5E
Error: connect error: Connection refused (111)
[4D:69:98:0E:91:5E][LE]> exit
➜  ~  sudo gatttool  -t random  -b 4D:69:98:0E:91:5E -I
[4D:69:98:0E:91:5E][LE]> connect
Attempting to connect to 4D:69:98:0E:91:5E
Connection successful
[4D:69:98:0E:91:5E][LE]> 
(gatttool:3104): GLib-WARNING **: Invalid file descriptor.

过壹回会10S自动断开,网络说这些工具老了,不提议用了([#2](https://www.spinics.net/lists/linux-bluetooth/msg67617.html)):

There are new tools to use with GATT, bluetoothctl/bluetoothd is the preferred since with that you have GAP, etc, 
but if want to use a stand alone tool then I suggest you use btgatt-client.

美高梅4688am 5

  张开IE浏览器,依次打开 【Internet】→【高端】,在 设置 选项卡中,勾选【使用TLS1.0】,然后点击【明确】保存修改,重启浏览器就能够。

 

再次出现蒙受:XP sp3 / Office 二零零七(其余office版本应该也得以,未有测验)

先是局地:配置及驾驭宿主机上VMware Workstation的设想网络

  1. #### 张开 VMware Workstation,选用菜单栏上的编纂,进入 虚拟互连网编辑器 美高梅4688am 6

  2. #### 点击退换设置,获取管理员权限

    美高梅4688am 7

  3. #### 选择 NET模式(VMnet8),点击 DHCP 设置

    美高梅4688am 8

  4. #### 记住DHCP的起止IP地址,例如:图示为 192.168.18.10~254

    美高梅4688am 9

  5. #### 选择 NET模式(VMnet8),点击 NAT设置

    美高梅4688am 10

  6. #### 记住网关 IP ,比方:图示为 192.168.18.2

    美高梅4688am 11

  7. #### 相当多年青人伴会开掘,这里网关是192.168.18.2,为何设置成192.168.18.1就这一个呢?

  8. #### 跻身系统的互联网连接面板,找到VMware Network Adapter VMnet8,右击选择景况 美高梅4688am 12

  9. #### 点击详细新闻,查看IPv4地址,能够见到是192.168.18.1

    从一些角度来讲,可以领略为VMware在Computer里创设了三个设想路由器,虚构机连接到路由器中,然后路由器作为叁个虚构网和宿主机物理网的连年,路由器就必就要有地址,即IP,所以才会是所看到的192.168.18.1
    **
    美高梅4688am 13美高梅4688am 14**

3、bluetoothctl——NB的新工具

一声令下行进入bluetoothctl操作碰着([#6](https://mcuoneclipse.com/2016/12/19/tutorial-ble-pairing-the-raspberry-pi-3-model-b-with-hexiwear/))

bluetoothctl

自个儿在哥哥大上用lightblue模拟一个BLE设备ty_prod,之后对其service实行修改,调用scan on进行搜寻还是老的,
末尾发掘要先用remove移除以前的器具,之后再scan就能够冒出[NEW] Device 72:3B:E1:81:4E:4F ty_prod设备
注: 用lightblue模拟的装置的MAC不是固定的
注: 作者发觉在lightblue中不管怎么模拟BLE设备,一旦被连上找寻到的service都以IPone的

[bluetooth]# devices
Device 28:ED:6A:A0:26:B7 ty_prod
Device 58:71:33:00:00:24 Bluetooth Keyboard
Device 00:1A:7D:DA:71:0A SHEN-PC
Device 94:87:E0:B3:AC:6F Mi Phone
[bluetooth]# remove 28:ED:6A:A0:26:B7 
...
[bluetooth]# scan on
Discovery started
[NEW] Device 72:3B:E1:81:4E:4F ty_prod
[bluetooth]# scan off
...
Discovery stopped
[bluetooth]# connect 72:3B:E1:81:4E:4F
Attempting to connect to 72:3B:E1:81:4E:4F
[CHG] Device 72:3B:E1:81:4E:4F Connected: yes
Connection successful
[ty_prod]

几乎就用三星手机自带的劳务做测验了~

[ty_prod]# info
Device 28:ED:6A:A0:26:B7 (public)
    Name: tuya_mdev_test
    Alias: tuya_mdev_test
    Appearance: 0x0040
    Icon: phone
    Paired: yes
    Trusted: no
    Blocked: no
    Connected: yes
    LegacyPairing: no
    UUID: Fax                       (00001111-0000-1000-8000-00805f9b34fb)
    UUID: Generic Access Profile    (00001800-0000-1000-8000-00805f9b34fb)
    UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
    UUID: Current Time Service      (00001805-0000-1000-8000-00805f9b34fb)
    UUID: Device Information        (0000180a-0000-1000-8000-00805f9b34fb)
    UUID: Battery Service           (0000180f-0000-1000-8000-00805f9b34fb)
    UUID: Vendor specific           (7905f431-b5ce-4e99-a40f-4b1e122d00d0)
    UUID: Vendor specific           (89d3502b-0f36-433a-8ef4-c502ad55f8dc)
    UUID: Vendor specific           (9fa480e0-4967-4542-9390-d343dc5d04ae)
    UUID: Vendor specific           (d0611e78-bbb4-4591-a5f8-487910ae4366)
[CHG] Device 28:ED:6A:A0:26:B7 ServicesResolved: no
[CHG] Device 28:ED:6A:A0:26:B7 Connected: no

作者们用Current Time Service,列出富有attributes操作如下:

[tuya_mdev_test]# menu gatt
[tuya_mdev_test]# list-attributes 28:ED:6A:A0:26:B7
...
Primary Service
    /org/bluez/hci0/dev_47_B1_26_C1_81_18/service0041
    00001805-0000-1000-8000-00805f9b34fb
    Current Time Service
Characteristic
    /org/bluez/hci0/dev_47_B1_26_C1_81_18/service0041/char0045
    00002a0f-0000-1000-8000-00805f9b34fb
    Local Time Information
Characteristic
    /org/bluez/hci0/dev_47_B1_26_C1_81_18/service0041/char0042
    00002a2b-0000-1000-8000-00805f9b34fb
    Current Time
Descriptor
    /org/bluez/hci0/dev_47_B1_26_C1_81_18/service0041/char0042/desc0044
    00002902-0000-1000-8000-00805f9b34fb
    Client Characteristic Configuration
...

上面Current Time Service相应的劳务如下图:

美高梅4688am 15

咱俩选拔Current 提姆e实行操作UUID:0x2A2B

[ty_prod]# select-attribute /org/bluez/hci0/dev_47_B1_26_C1_81_18/service0041/char0042
[tuya_mdev_test:/service0041/char0042]# read
Attempting to read /org/bluez/hci0/dev_47_B1_26_C1_81_18/service0041/char0042
[CHG] Attribute /org/bluez/hci0/dev_47_B1_26_C1_81_18/service0041/char0042 Value:
  e2 07 09 05 01 24 11 03 f1 02                    .....$....      
  e2 07 09 05 01 24 11 03 f1 02                    .....$.... 
[tuya_mdev_test:/service0041/char0042]# attribute-info
Characteristic - Current Time
    UUID: 00002a2b-0000-1000-8000-00805f9b34fb
    Service: /org/bluez/hci0/dev_47_B1_26_C1_81_18/service0041
    Value:
  e2 07 09 05 01 2e 01 03 f5 02                    ..........      
    Notifying: yes
    Flags: read
    Flags: notify

读出结果大约意思应该是:2018-9/5-1:36:17 周三

读取一下0x180A的Device Information:

[tuya_mdev_test:/service0006/char0007]# select-attribute /org/bluez/hci0/dev_47_B1_26_C1_81_18/service0047/char004a
[tuya_mdev_test:/service0047/char004a]# attribute-info
Characteristic - Model Number String
    UUID: 00002a24-0000-1000-8000-00805f9b34fb
    Service: /org/bluez/hci0/dev_47_B1_26_C1_81_18/service0047
    Flags: read
[tuya_mdev_test:/service0047/char004a]# read
Attempting to read /org/bluez/hci0/dev_47_B1_26_C1_81_18/service0047/char004a
[CHG] Attribute /org/bluez/hci0/dev_47_B1_26_C1_81_18/service0047/char004a Value:
  69 50 68 6f 6e 65 36 2c 32                       iPhone6,2       
  69 50 68 6f 6e 65 36 2c 32                       iPhone6,2    

道理当然是那样的写、使能notify也很轻便,看help即可。最后断开连接、并脱离!!!

[tuya_mdev_test:/service0047/char004a]# disconnect 28:ED:6A:A0:26:B7
Attempting to disconnect from 28:ED:6A:A0:26:B7
[CHG] Device 28:ED:6A:A0:26:B7 ServicesResolved: no
Successful disconnected
[CHG] Device 28:ED:6A:A0:26:B7 Connected: no
[bluetooth]# quit

美高梅4688am 16

 

PS1:稍稍朋友会问为啥不选用桥接大概Host-Only?

  • 首先,Host-Only不协助联网,Host-Only网络的虚构机只好与该宿主机通讯,并不能够与外场连通
  • 其次,NET方式能够清楚为是能够联网的Host-Only方式
  • 再次,NEt方式能很好的解释网络陈设上常蒙受的标题,最常见的正是网关的装置,其次正是展开DHCP后的起止IP地址的难题
  • 相比较于上述三种,桥接形式就能显得轻巧非常多,然而会有多数难点,对于实验景况,少不了静态IP,可是只要切换宿主机网络,大家的设想机就须要重新安装静态网络
  • 之所以建议选取NET情势
  • 其次有些的步子会适用于 二种网络的静态方式和DHCP形式

LINKS

[1].Cannot connect to BLE device on Raspberry Pi
[2].Invalid file descriptor gatttool of bluez 5.32
[3].Get Started with Bluetooth Low Energy on Linux
[绘制基础,hang的由来分析。4].Reverse Engineering a Bluetooth Low Energy Light Bulb
[5].Doing Bluetooth Low Energy on Linux
[6].Tutorial: BLE Pairing the Raspberry Pi 3 Model B with Hexiwear

美高梅4688am 17

@beautifulzzzz
智能硬件、物联网,热爱技术,关注产品
博客:http://blog.beautifulzzzz.com
园友交流群:414948975

1> 解压iqy_test.zip

其次片段:配置CentOS7 设想机

2> 运行http_server.py(需先安装python)

在初阶以下步骤前,确认保证连接的是 NET情势网络 或然 桥接互连网

  1. #### 展现互联网设施的运涨势况

    1 [root@sxy ~]$ ip link
    
  2. #### 彰显互连网接口的互连网参数

    1 [root@sxy ~]$ ip addr
    
  3. #### 修改网卡消息–ONBOOT

    1 [root@sxy ~]$ vi /etc/sysconfig/network-scripts/ifcfg-exxxxxx
    2 ##找到ONBOOT参数,将no改为yes,即设置网卡开机自启
    3 ONBOOT=yes
    
  4. #### 重启互连网服务

    1 [root@sxy ~]$ systemctl restart network
    
  5. #### 检验网络连通性

    1 [root@sxy ~]$ ping 114.114.114.114 -c 3
    2 PING 114.114.114.114 (114.114.114.114) 56(84) bytes of data.
    3 64 bytes from 114.114.114.114: icmp_seq=1 ttl=67 time=1.55 ms
    4 64 bytes from 114.114.114.114: icmp_seq=2 ttl=70 time=1.47 ms
    5 64 bytes from 114.114.114.114: icmp_seq=3 ttl=65 time=1.54 ms
    6 
    7 --- 114.114.114.114 ping statistics ---
    8 3 packets transmitted, 3 received, 0% packet loss, time 2003ms
    9 rtt min/avg/max/mdev = 1.472/1.522/1.554/0.057 ms
    
  6. #### 至此,使用DHCP分配IP联网就马到功成了,上边包车型大巴步骤介绍配置static静态IP

  7. #### 呈现网络接口的网络参数-查看当前IP

    1 ##记录现有DHCP分配的ip地址
    2 [root@sxy ~]$ ip addr
    
  8. #### 修改网卡音讯–IP

    1 [root@sxy ~]$ vi /etc/sysconfig/network-scripts/ifcfg-exxxxxxx
    2 
    3 BOOTPROTO=static              将dhcp更改为static
    4 IPADDR=XXX.XXX.XXX.XXX        填写上一个步骤里对应网卡下的IP 地址
    5 NETMASK=255.255.255.0
    6 GATEWAY=XXX.XXX.XXX.XXX       填写之前虚拟网的网关地址
    
  9. #### 重启互连网服务

    1 [root@sxy ~]$ systemctl restart network
    
  10. #### 再度检验互连网连通性

     1 [root@sxy ~]$ ping 114.114.114.114 -c 3
     2 ## 只要能ping通114.114.114.114,就意味着在网上了
     3 PING 114.114.114.114 (114.114.114.114) 56(84) bytes of data.
     4 64 bytes from 114.114.114.114: icmp_seq=1 ttl=67 time=1.55 ms
     5 64 bytes from 114.114.114.114: icmp_seq=2 ttl=70 time=1.47 ms
     6 64 bytes from 114.114.114.114: icmp_seq=3 ttl=65 time=1.54 ms
     7 
     8 --- 114.114.114.114 ping statistics ---
     9 3 packets transmitted, 3 received, 0% packet loss, time 2003ms
    10 rtt min/avg/max/mdev = 1.472/1.522/1.554/0.057 ms
    
  11. #### 检查实验域名分析

    1 [root@sxy ~]$ ping baidu.com
    2 ping: unknown host baidu.com
    
  12. #### 配置域名深入分析

    1 [root@sxy ~]$ vi /etc/resolv.conf
    2 
    3 nameserver 114.114.114.114
    4 nameserver 8.8.8.8
    

    #### 或者

    1 [root@sxy ~]$ vi /etc/sysconfig/network-scripts/ifcfg-exxxxxxx
    2 
    3 ##添加下两行,
    4 DNS1=114.114.114.114
    5 DNS2=8.8.8.8
    
  13. #### 再一次检查评定域名分析

     1 [root@sxy ~]$ ping baidu.com -c 3
     2 
     3 PING 114.114.114.114 (114.114.114.114) 56(84) bytes of data.
     4 64 bytes from 114.114.114.114: icmp_seq=1 ttl=67 time=1.55 ms
     5 64 bytes from 114.114.114.114: icmp_seq=2 ttl=70 time=1.47 ms
     6 64 bytes from 114.114.114.114: icmp_seq=3 ttl=65 time=1.54 ms
     7 
     8 --- 114.114.114.114 ping statistics ---
     9 3 packets transmitted, 3 received, 0% packet loss, time 2003ms
    10 rtt min/avg/max/mdev = 1.472/1.522/1.554/0.057 ms
    
  14. #### 以上就到位了从基础配置到系统设置的全经过

  15. 美高梅4688am,#### 桥接步骤毫无二致,然则急需精通网关,日常都以X.X.X.1

  16. #### Complete!!!

3> 执行"shell_execute.exe test.iqy"

shell_execute.exe的主要code:

bool shell_execute_file(wstring file_path)
{
    SHELLEXECUTEINFOW shell_exec_info = { 0 };
    shell_exec_info.cbSize = sizeof(SHELLEXECUTEINFOW);
    shell_exec_info.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI;
    shell_exec_info.hwnd = NULL;
    shell_exec_info.lpVerb = NULL;
    shell_exec_info.lpFile = file_path.c_str();
    shell_exec_info.lpParameters = NULL;
    shell_exec_info.lpDirectory = NULL;
    shell_exec_info.nShow = SW_SHOW;
    shell_exec_info.hInstApp = NULL;
    bool ret = ShellExecuteExW(&shell_exec_info);
    printf("process handle is %pn", shell_exec_info.hProcess);

    return ret;
}

 

本文由美高梅4688am发布于美高梅4688am,转载请注明出处:绘制基础,hang的由来分析

关键词: