1 软件功能

该软件用于在Linux平台测试CH35X/CH38X(PCI/PCIe转串并口)的并口各引脚功能是否正常。方便对设备进行出厂测试。

2 并口测试硬件治具

在测试前,需要制作单独的硬件治具,按下表连接信号线:

25针并口座子堵头硬件连线

引脚名

引脚号

引脚名

引脚号

BUSY

11

----------------------

D7

9

ACK

10

----------------------

D6

8

PE

12

----------------------

D5

7

SELT

13

----------------------

D4

6

ERR

15

----------------------

D6

8

SIN

17

----------------------

D3

5

INIT

16

----------------------

D2

4

AFD

14

----------------------

D1

3

STB

1

----------------------

D0

2

引脚连接示意图:

3 软件使用方法

  • 插入待测试PCI/PCIe转并口设备。
  • 输入lspci –v命令查看设备的枚举信息,若找到厂商ID为[1C00]或[4348]的设备,则表示已经正常识别到该硬件。

  • 通过lsmod命令查看设备关联驱动是否已加载,设备所需驱动包括:parport、parport_pc、lp驱动。驱动加载后,查看系统/dev目录,会多出parportX(X为数字)节点,示例:

  • 编译测试程序,生成目标可执行程序,输入./parport_test -D /dev/parport0 –h命令查看帮助,输出其他命令无效。运行程序:[可执行文件名] -D [设备节点名称] –s

4 测试错误码说明

根据输出的错误码和终端输出信息可判断故障信号线,下表为错误码和说明。

错误码

错误码说明

0

STB-D0通讯错误

1

AFD-D1通讯错误

2

INIT-D2通讯错误

3

SIN-D3通讯错误

4

D6-ERR通讯错误

5

D4-SELT通讯错误

6

D5-PE通讯错误

7

D6-ACK通讯错误

8

D7-BUSY通讯错误

5 测试实例

测试成功实例

测试错误实例

根据输出信息,D4-SELT、D5-PE、D6-ACK和D7-BUSY信号通讯存在错误。

根据输出信息,STB-D0信号通讯存在错误。

6、wchparporttest工具源码

/** parport factory test utility.** Copyright (C) 2023 Nanjing Qinheng Microelectronics Co., Ltd.* Web:     http://wch.cn* Author:  WCH <tech@wch.cn>** This program is free software; you can redistribute it and/or modify* it under the terms of the GNU General Public License as published by* the Free Software Foundation; either version 2 of the License, or* (at your option) any later version.** Cross-compile with cross-gcc -I /path/to/cross-kernel/include** V1.0 - initial version**/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <asm/ioctl.h>
#include <sys/ioctl.h>
#include <linux/ppdev.h>
#include <linux/parport.h>
#include <getopt.h>#define GET_BIT(x, y)       ((x >> y) & 0x01) /* get y bit value of x */
#define CTRL_REG_INITVAL_OUT 0xc0          /* control reg value(allow D7-D0 output) */
#define CTRL_REG_INITVAL_IN  0xe0          /* control reg value(forbid D7-D0 output) */static unsigned char ctrlval = 0;
static char device_name[20];/*** ctrl_reg_update: update PCR reg* @fd: file descriptor* @mask: bits to update* @val: 0->clear, 1->set*/
void ctrl_reg_update(int fd, unsigned char mask, unsigned char val)
{int ret;ctrlval &= ~mask;ctrlval |= val & mask;ret = ioctl(fd, PPWCONTROL, &ctrlval);if (ret < 0) {perror("ioctl");return;}
}/*** data_line_init: data signals direction initialization* @fd: file descriptor* @dir: direction value* * The function return 0 if successful, others if fail.*/
int data_line_init(int fd, int dir)
{int ret;if (dir == 0)ctrlval = CTRL_REG_INITVAL_IN;elsectrlval = CTRL_REG_INITVAL_OUT;ret = ioctl(fd, PPWCONTROL, &ctrlval);if (ret < 0) {perror("ioctl");return -1;}return 0;
}/*** data_reg_read: read data signals* @fd: file descriptor* * The function return positive if successful, negative if fail.*/
unsigned char data_reg_read(int fd)
{int ret;unsigned char data_r;ret = ioctl(fd, PPRDATA, &data_r);if (ret < 0) {perror("ioctl");return -1;}return data_r;
}/*** print_err_msg: print message according to error code* @err_code: error number* */
static void print_err_msg(int err_code)
{switch (err_code) {case 0:printf("[error code: %d] STB-D0 ERROR\n", err_code);break;case 1:printf("[error code: %d] AFD-D1 ERROR\n", err_code);break;case 2:printf("[error code: %d] INIT-D2 ERROR\n", err_code);break;case 3:printf("[error code: %d] SIN-D3 ERROR\n", err_code);break;case 4:printf("[error code: %d] D6-ERR ERROR\n", err_code);break;case 5:printf("[error code: %d] D4-SELT ERROR\n", err_code);break;case 6:printf("[error code: %d] D5-PE ERROR\n", err_code);break;case 7:printf("[error code: %d] D6-ACK ERROR\n", err_code);break;case 8:printf("[error code: %d] D7-BUSY ERROR\n", err_code);break;default:break;}
}/*** check_result: detect whether the current register value matches the target value related bits, and print in case of error* @type: test type, 0x01: control line output, data line input, 0x02: data line output, status line input* @val: current register value* @cmp_val: target register value* * The function return 0 if successful, negative if fail.*/
static int check_result(int type, unsigned char val, unsigned char cmp_val)
{int i;int ret = 0;if (type == 0x01) {for (i = 0; i < 4; i++) {if (GET_BIT(val, i) != GET_BIT(cmp_val, i)) {ret = -1;print_err_msg(i);}}} else if (type == 0x02) {for (i = 3; i < 8; i++) {if (GET_BIT(val, i) != GET_BIT(cmp_val, i)) {ret = -1;print_err_msg(i + 1);}}} else {printf("type error.n");return -1;}return ret;
}static const struct option lopts[] = {{ "device name", required_argument, 0, 'd' },{ "start test", no_argument, 0, 's' },{ "view the usage method", no_argument, 0, 'h' },{ NULL, 0, 0, 0 },
};static void print_usage(const char *prog)
{printf("Usage: %s [-dsh]\n", prog);puts("  -d device name\n""  -s start test\n""  -h view the usage method");exit(1);
}static void help_msg(void)
{puts("Pin connection mode of parport test:\n""test1(PDR OUT/PSR IN): D6-ERR D4-SELT D5-PE D6-ACK\n""test2(PCR OUT/PIR IN): STB-D0 AFD-D1 INIT-D2 SIN-D3 D7-BUSY");exit(1);
}static void parse_opts(int argc, char *argv[])
{char c;if (argc != 4)print_usage(argv[0]);while (1) {c = getopt_long(argc, argv, "d:sh", lopts, NULL);if (c == -1)break;switch (c) {case 'd':memcpy(device_name, argv[2], strlen(argv[2]));break;case 's':printf("start test...\n");break;case 'h':help_msg();break;default:print_usage(argv[0]);break;}}
}int main(int argc, char **argv)
{int fd;int retval;int ret_check1, ret_check2, ret_check3, ret_check4;unsigned char data_w, status_r;parse_opts(argc, argv);/* Open parport device */fd = open(device_name, O_RDWR);if (fd < 0) {perror("open");return -1;}/* Claim the port */if ((retval = ioctl(fd, PPCLAIM)) < 0) {perror("PPCLAIM failed");goto exit;}/* Set the direction of D0-D7 to output */if ((retval = data_line_init(fd, 0x01)) < 0)goto exit;/* Set D0-D7 output low level */data_w = 0x00;if ((retval = ioctl(fd, PPWDATA, &data_w)) < 0) {perror("PPWDATA ioctl");goto exit;}/* Read BUSY, ACK, PE, SELT and ERR signal, judge whether they are all low */if ((retval = ioctl(fd, PPRSTATUS, &status_r)) < 0) {perror("PPRSTATUS ioctl");goto exit;}ret_check1 = check_result(0x02, status_r, 0x87);/* Set D4-D7 output high level */data_w = 0xf0;if ((retval = ioctl(fd, PPWDATA, &data_w)) < 0) {perror("PPWDATA ioctl");goto exit;}/* Read BUSY, ACK, PE, SELT and ERR signal, judge whether they are all high */if ((retval = ioctl(fd, PPRSTATUS, &status_r)) < 0) {perror("PPRSTATUS ioctl");goto exit;}ret_check2 = check_result(0x02, status_r, 0x7b);/* Set the direction of D0-D7 to input */if ((retval = data_line_init(fd, 0x00)) < 0)goto exit;/* Set SIN, INIT, AFD and STB output low level */ctrl_reg_update(fd, 0x0f, 0x0b);/* Read D0-D4 signal, judge whether they are all low */ret_check3 = check_result(0x01, data_reg_read(fd), 0xf0);/* Set SIN, INIT, AFD and STB output high level */ctrl_reg_update(fd, 0x0f, 0x04);/* Read D0-D4 signal, judge whether they are all high */ret_check4 = check_result(0x01, data_reg_read(fd), 0xff);if ((ret_check1 == 0) && (ret_check2 == 0) && (ret_check3 == 0) && (ret_check4 == 0))printf("Parport pin test passed\n");elseprintf("Parport pin test failed\n");exit:/* Release the port */if (ioctl(fd, PPRELEASE) < 0)perror("PPRELEASE failed");close(fd);return retval;
}

Linux打印口/LPT口出厂测试工具与使用说明相关推荐

  1. Windows串口出厂测试工具与使用说明

    WCHUsbSerTest是一款用于WCH USB转串口系列产品出厂测试的工具软件,方便用户对产品进行批量化功能测试.该软件支持以下特性: 支持设备热插拔检测,插入自动测试. 支持两种测试模式:1个设 ...

  2. http压力测试工具及使用说明

    说明:介绍几款简单.易使用http压测工具,便于研发同学,压测服务,明确服务临界值,寻找服务瓶颈点. 压测时候可重点以下指标,关注并发用户数.TPS(每秒事务数量).RT(事务响应时间).事物失败率. ...

  3. benchmarksql测试mysql_数据库压力测试工具 -- BenchmarkSQL 使用说明

    关于数据库的压力测试,之前写过3篇Blog: 数据库基准测试(Database Benchmarking) 说明 数据库压力测试工具 -- Hammerdb 使用说明 数据库压力测试工具 -- Swi ...

  4. linux 渗透工具_适用于Linux的十大最佳渗透测试工具

    linux 渗透工具 This article covers some of the best penetration testing tools for Linux Cybersecurity is ...

  5. linux下的web服务器压力测试工具之ab

    介绍 ab是apache附带的一款压力测试工具,它非常容易使用,ab可以直接在Web服务器本地发起测试请求.这至关重要,因为我们希望测试的服务器的处理时间,而不包含数据的网络传输时间以及用户PC本地的 ...

  6. 压力测试ab安装 linux,Centos8下安装ab压力测试工具及ab命令详解

    释放双眼,带上耳机,听听看~! 1.ab的简介 ab是apachebench命令的缩写. ab是apache自带的压力测试工具.ab非常实用,它不仅可以对apache服务器进行网站访问压力测试,也可以 ...

  7. linux查看iozone安装目录,IOZONE测试工具使用方法

    IOZONE测试工具使用方法 IOZONE主要用来测试操作系统文件系统性能的测试工具,该工具所测试的范围主要有,write , Re-write, Read, Re-Read, Random Read ...

  8. 串口 COM口,并口 LPT口,RS232、RS485、CAN、PC卡 及DAQ

    计算机的数据传送能力会极大地影响数据采集系统.所有PC都具有可编程I/O 和中断传送方式.目前绝大多数个人计算机可以使用直接存储器访问[DMA Direct Memory Access]传送方式,它使 ...

  9. fio模拟mysql写入速度_IO压力测试工具 -- FIO 使用说明

    1FIO安装 FIO 工具用来测试裸盘的IO性能,直接操作存储设备,当然,在测试的时候,对会整个设备进行读写.如果不想对整盘进行操作,可以先用dd 命令,创建出一个文件,放在存储设备上,然后使用该文件 ...

最新文章

  1. HDOJ1871 无题
  2. Xamarin XAML语言教程Xamarin.Forms中程序状态与进度(一)
  3. tnsnames.ora无法保存的问题
  4. JSON的C语言编解码器——cJSON和json-c
  5. Win10系统电脑查看无线密码的方法
  6. seo提交工具_经验分享:SEO新手面对新网站应该如何去优化
  7. 三个月可更改用户昵称两次
  8. MSDN Visual系列:用WSSv3中的SPGridView控件来显示数据
  9. java的代码大全_java代码大全
  10. 网络工程制图论文计算机,计算机工程制图教学的课业评价-计算机工程论文-计算机论文.docx...
  11. 地图瓦片坐标系定义及计算原理
  12. 12.31 icpc 南京站
  13. 小孩孩子应用题计算机错误,为什么一二年级的孩子数学应用题总出错?家长该怎么办?...
  14. 读书笔记,《刻意练习》,第三章,心理表征
  15. 509.斐波那契数列
  16. 睡眠助手APP开发解决方案
  17. php int 32 64,php从32位升级到64位需要注意的几点
  18. Android之Mob第三方短信验证服务
  19. 微软软件开发技术二十年回顾-COM、OLE、ActiveX及COM+篇
  20. python 安装 SimpleITK 和 pydicom

热门文章

  1. [小说连载]张小庆,在路上(19)- 真的要在北京吗
  2. TYPE-C接口安卓手机直播快充领夹式无线麦克风方案
  3. Android SELinux开发入门指南之正确姿势解决访问data目录权限问题
  4. python微信公众号开发音乐功能_python利用微信公众号实现报警功能
  5. Batch Normation
  6. laravel excel 2.1
  7. 【pytest】内置 fixtures 之 tmpdir:创建临时文件
  8. centos7 安装英伟达驱动;cuda;docker离线安装;docker gpu离线安装;制作自己的cuda镜像;安装 容器中ssh协议
  9. 商业图表案例3-CO2排放量与人均GDP
  10. excel 模拟分析 - 单变量求解模拟运算表