精华内容
下载资源
问答
  • C++串口编程

    万次阅读 多人点赞 2018-06-03 13:08:40
    // 定义串口类型 #ifdef _UNICODE typedef CString porttype; #else typedef std::string porttype; #endif // _UNICODE typedef unsigned long ulong; typedef unsigned char uchar; class CSerialPort { public...

    CSerialPort 类,头文件: SerialPort.h

    #ifndef _SERIAL_H
    #define _SERIAL_H
    
    #include <string>
    #include <Windows.h>
    #include <cstddef>
    #include <cstdlib>
    #include <cassert>
    
    // 定义串口类型
    #ifdef _UNICODE
    typedef CString porttype;
    #else
    typedef std::string porttype;
    #endif // _UNICODE
    
    typedef unsigned long ulong;
    typedef unsigned char uchar;
    
    
    class CSerialPort
    {
    public:
    	CSerialPort(
    		const porttype & portNum,		// 串口号
    		DWORD baudRate = 9600,			// 波特率
    		BYTE  byteSize = 8,				// 数据位
    		BYTE  parityBit = NOPARITY,		// 检验位
    		BYTE  stopBit = ONESTOPBIT		// 停止位
    		);
    
    	~CSerialPort();
    
    public:
    
    	bool openComm();										// 打开串口
    	void closeComm();										// 关闭串口
    	bool writeToComm(BYTE data[], DWORD dwLegnth);			// 发送数据
    	bool readFromComm(char buffer[], DWORD dwLength);		// 读取数据
    
    private:
    
    	HANDLE m_hComm;		// 通信设备
    	porttype m_portNum; // 串口号
    	DWORD m_dwBaudRate; // 波特率
    	BYTE  m_byteSize;	// 数据位
    	BYTE  m_parityBit;  // 校验位
    	BYTE  m_stopBit;	// 停止位
    	bool  m_bOpen;		// 串口开关标志
    private:
    	
    	enum BufferSize
    	{
    		MIN_BUFFER_SIZE = 256,
    		BUFFER_SIZE = 512,
    		MAX_BUFFER_SIZE = 1024
    	};
    
    	// 设置串口号
    	void setPortNum(const porttype &portNum)
    	{
    		this->m_portNum = portNum;
    	}
    	// 设置波特率
    	void setBaudRate(const ulong baudRate)
    	{
    		this->m_dwBaudRate = baudRate;
    	}
    	// 设置数据位
    	void setByteSize(const uchar byteSize)
    	{
    		this->m_byteSize = byteSize;
    	}
    	// 设置检验位
    	void setParityBit(const uchar parityBit)
    	{
    		this->m_parityBit = parityBit;
    	}
    	// 设置停止位
    	void setStopBit(const uchar stopBit)
    	{
    		this->m_stopBit = stopBit;
    	}
    
    	// 获取串口号
    	porttype getPortNum() { return m_portNum; }
    	// 获取波特率
    	ulong getBaudRate() { return m_dwBaudRate; }
    	// 获取数据位
    	uchar getByteSize() { return m_byteSize; }
    	// 获取检验位
    	uchar getParityBit() { return m_parityBit; }
    	// 获取停止位
    	uchar getStopBit() { return m_stopBit; }
    };
    
    
    
    
    #endif		// _SERIAL_H

    SerialPort 类实现文件 .cpp:

    #include "stdafx.h"
    #include "Serial.h"
    
    CSerialPort::CSerialPort(
    	const porttype & portNum,
    	DWORD baudRate /* = 9600 */,
    	BYTE byteSize /* = 8 */,
    	BYTE parityBit /* = NOPARITY */,
    	BYTE stopBit /* = ONESTOPBIT */
    	) : m_portNum(portNum),
    	m_dwBaudRate(baudRate),
    	m_byteSize(byteSize),
    	m_parityBit(parityBit),
    	m_stopBit(stopBit),
    	m_bOpen(false)
    {
    
    }
    
    CSerialPort::~CSerialPort()
    {
    
    }
    
    // 打开串口成功,返回 true
    
    bool CSerialPort::openComm()
    {
    #ifdef _UNICODE
    	m_hComm = CreateFile(m_portNum,
    		GENERIC_READ | GENERIC_WRITE, //允许读和写
    		0,		//独占方式
    		NULL, OPEN_EXISTING,   //打开而不是创建
    		0,   //同步方式
    		NULL
    		);
    #else
    	m_hComm = CreateFileA(m_portNum.c_str(),
    		GENERIC_READ | GENERIC_WRITE, //允许读和写
    		0,		//独占方式
    		NULL, OPEN_EXISTING,   //打开而不是创建
    		0,   //同步方式
    		NULL
    		);
    #endif
    
    	if (m_hComm == INVALID_HANDLE_VALUE)
    	{
    #ifdef _UNICODE
    		TCHAR szBuf[1024] = { 0 };
    		wsprintf(szBuf, L"打开 %s 失败,代码: %d", m_portNum, GetLastError());
    		MessageBox(NULL, szBuf, L"Warnning", MB_OK);
    #else
    		char szBuf[1024] = { 0 };
    		sprintf_s(szBuf, "打开 %s 失败,代码: %d", m_portNum, GetLastError());
    		MessageBox(NULL, szBuf, "Warnning", MB_OK);
    #endif // _UNICODE
    
    		return false;
    
    	}
    	else
    	{
    		DCB dcb;
    		SetupComm(m_hComm, MAX_BUFFER_SIZE, MAX_BUFFER_SIZE);	// 设置读写缓冲区大小
    		GetCommState(m_hComm, &dcb);
    		dcb.BaudRate = m_dwBaudRate;
    		dcb.ByteSize = m_byteSize;
    		dcb.Parity = m_parityBit;
    		dcb.StopBits = m_stopBit;
    
    		if (!SetCommState(m_hComm, &dcb))
    		{
    #ifdef _UNICODE
    			TCHAR szBuf[1024] = { 0 };
    			wsprintf(szBuf, L"串口设置失败,错误代码: %d", GetLastError());
    			MessageBox(NULL, szBuf, TEXT("ERROR"), MB_OK);
    #else
    			char szBuf[1024] = { 0 };
    			wsprintf(szBuf, "串口设置失败,错误代码: %d", GetLastError());
    			MessageBox(NULL, szBuf, "ERROR", MB_OK);
    #endif
    			return false;
    		}
    
    	}
    
    	//在读写串口前,用 PurgeComm 函数清空缓冲区
    	PurgeComm(m_hComm, PURGE_RXCLEAR | PURGE_TXCLEAR | PURGE_TXABORT | PURGE_TXABORT);
    
    	m_bOpen = true;
    
    	return true;
    
    }
    
    // 关闭串口
    
    void CSerialPort::closeComm()
    {
    	CloseHandle(m_hComm);
    }
    
    
    // 向串口发送数据
    bool CSerialPort::writeToComm(BYTE data[], DWORD dwLength)
    {
    #ifdef _DEBUG
    	assert(m_bOpen == true || dwLength > 0);
    	return false;
    #endif // _DEBUG
    	DWORD dwError = 0;
    	if (ClearCommError(m_hComm, &dwError, NULL) && dwError > 0)
    	{
    		PurgeComm(m_hComm, PURGE_TXABORT | PURGE_TXCLEAR);
    	}
    
    	DWORD dwTx = 0;
    	BOOL ret = FALSE;
    	ret = WriteFile(m_hComm, data, dwLength, &dwTx, NULL);
    
    	if (ret == FALSE)
    	{
    #ifdef _UNICODE
    		TCHAR szBuf[1024] = { 0 };
    		wsprintf(szBuf, _T("读取数据失败,错误代码: %d"), GetLastError());
    		MessageBox(NULL, szBuf, L"ERROR", MB_OK);
    #else
    		char szBuf[1024] = { 0 };
    		sprintf_s(szBuf, "读取数据失败, 错误代码: %d", GetLastError());
    		MessageBox(NULL, szBuf, "Error", MB_OK);
    #endif // _UNICODE
    
    		return false;
    	}
    
    	return true;
    
    
    }
    
    // 从串口中读取数据
    
    bool CSerialPort::readFromComm(char buffer[], DWORD dwLength)
    {
    #ifdef _DEBUG
    	assert(m_bOpen == true || dwLength > 0);
    	return false;
    #endif // _DEBUG
    
    	COMSTAT comStat;
    	DWORD dwError = 0;
    	if (ClearCommError(m_hComm, &dwError, &comStat) && dwError > 0)
    	{
    		PurgeComm(m_hComm, PURGE_RXABORT | PURGE_RXCLEAR);
    	}
    
    	DWORD dwRx = 0;		// 读入的字节数
    	BOOL ret = FALSE;
    	BYTE* byReadData = new BYTE[dwLength];
    	char szTmp[4] = { 0 };
    	int sizeOfBytes = sizeof(szTmp);
    	ret = ReadFile(m_hComm, byReadData, dwLength, &dwRx, NULL);	// 读入数据
    
    	if (ret == TRUE)
    	{
    		for (int i = 0; i < dwRx; ++i)
    		{
    			sprintf_s(szTmp, "%02x", byReadData[i]);
    			strcat_s(buffer, sizeOfBytes*dwLength, szTmp);
    		}
    
    		// 释放内存
    		delete byReadData;
    
    		return true;
    	}
    	else
    	{
    #ifdef _UNICODE
    		TCHAR szBuf[1024] = { 0 };
    		wsprintf(szBuf, _T("数据读取失败,错误代码: %d"), GetLastError());
    		MessageBox(NULL, szBuf, L"Error", MB_OK);
    #else
    		char szBuf[1024] = { 0 };
    		wsprintf(szBuf, "数据读取失败,错误代码: %d", GetLastError());
    		MessageBox(NULL, szBuf, "Error", MB_OK);
    #endif // _UNICODE
    
    		return false;
    	}
    
    	return true;
    }
    

    #include <iostream>
    #include <cassert>
    #include "Serial.h"
    using namespace std;
     
    
    
    int main()
    {
    	CSerialPort serialPort("COM3");
    
    	BYTE sendData = 0x01;
    	char recvBuf[1024] = { 0 };
    
    	serialPort.openComm();
    	serialPort.writeToComm(&sendData, 1);
    	serialPort.readFromComm(recvBuf, 1);
    
    	serialPort.closeComm();
    
    	system("pause");
    	return 0;
    }


    展开全文
  • c++串口编程

    2016-03-26 10:39:38
    连接硬件串口
  • Visual C++串口编程

    2018-11-26 20:16:34
    VC串口编程指南,从 WIN32 API 到 MSCOMM 、SERIERPORT 类编程
  • C++串口串口编程调试源码,实测可用,有需要的可以下载看看
  • 深入浅出Visual C++串口编程 串口通信是Windows应用软件开发的重要环节,除了普通的通信软件外,还在工业控制领域有广泛的用途,因此掌握串口编程是每个程序员的必备技巧。 •无庸讳言,目前网上有不少介绍串口通信...
  • Linux C++ 串口编程 详解+实例

    千次阅读 2017-07-01 22:10:56
    Linux C++ 串口编程 详解+实例 大致步骤 Linux下的串口编程其实与Windows下无本质差别,说白了就是类似读写文件一样,对串口进行读写操作,用到的函数无非就是open,close,read,write函数等。具体的读写操作可...

    Linux C++ 串口编程 详解+实例

    大致步骤

    Linux下的串口编程其实与Windows下无本质差别,说白了就是类似读写文件一样,对串口进行读写操作,用到的函数无非就是open,close,read,write函数等。具体的读写操作可分为下面四个步骤

    1. 打开串口
    2. 配置串口
    3. 读写串口
    4. 关闭串口

    打开串口

    打开串口使用的是open函数,后缀第一个表示读写,第二个表示不允许进程干涉串口的读写操作(不太明白,实测发现终端输入会导致读写出错),第三个表示非阻塞。打开串口默认都是阻塞形式,使用标志位O_NDELAY可以设置为非阻塞模式,或者使用系统函数fcntl进行设置。
    fd = open(“/dev/ttyS*”, O_RDWR | O_NOCTTY | O_NDELAY);
    open可以接受的标志位如下:
    O_RDONLY只读模式
    O_WRONLY只写模式
    O_RDWR读写模式
    上述三个标志位必选其一
    ………………………………………………………………………………………………………………………………………………….
    O_APPEND每次写操作都写入文件的末尾
    O_CREAT如果指定文件不存在,则创建这个文件
    O_EXCL如果要创建的文件已存在,则返回 -1,并且修改 errno 的值
    O_TRUNC如果文件存在,并且以只写/读写方式打开,则清空文件全部内容
    O_NOCTTY如果路径名指向终端设备,不要把这个设备用作控制终端。
    O_NONBLOCK如果路径名指向 FIFO/块文件/字符文件,则把文件的打开和后继 I/O设置为非阻塞模式(nonblocking mode)
    下面三个常量同样是选用的,他们用于同步输入输出
    O_DSYNC等待物理 I/O 结束后再 write。在不影响读取新写入的数据的前提下,不等待文件属性更新。
    O_RSYNC读(read)等待所有写入同一区域的写操作完成后再进行
    O_SYNC等待物理 I/O 结束后再 write,包括更新文件属性的 I/O
    对于串口的打开操作,必须使用O_NOCTTY参数,它表示打开的是一个终端设备,程序不会成为该端口的控制终端。如果不使用此标志,任务的一个输入(比如键盘终止信号等)都会影响进程。
    O_NDELAY表示不关心DCD信号所处的状态(端口的另一端是否激活或者停止)
    打开串口后的句柄 “fd” 即代表了此串口,后续操作都是对句柄进行。

    配置串口

    串口配置主要包括波特率的配置,校验位,停止位的设置等等。具体如下:

     struct termios Opt;       //创建设置结构体,配置串口即改变结构体内元素的内容
     tcgetattr(fd, &Opt);      //保存原有的配置,保存在Opt中
     tcflush(fd, TCIOFLUSH);   //刷清输入输出队列
     cfsetispeed(&Opt, B9600); //设置输入波特率
     cfsetospeed(&Opt, B9600); //设置输出波特率

    波特率可以设置115200,9600等等,值得注意的是在设置波特率的时候要在前面加B。接下来设置停止位,校验位等等,依旧使用上述创建的结构体:

    Opt.c_cflag &= ~CSIZE;   //屏蔽数据位
    Opt.c_cflag  |= CS8; // 数据位为 8CS7 for 7 
    Opt.c_cflag &= ~CSTOPB;  // 一位停止位, 两位停止为 |= CSTOPB
    Opt.c_cflag &= ~PARENB;  // 无校验
    Opt.c_cflag |= PARENB;   //有校验
    Opt.c_cflag &= ~PARODD;   // 偶校验
    Opt.c_cflag |=  PARODD;   // 奇校验

    接下来设置一些时间参数:

    Opt.c_cc[VTIME] = 1;  //设置等待时间
    Opt.c_cc[VMIN] = 100;     //设置最小字节数

    时间参数只有在设置为阻塞模式下才能使用,VMIN代表读取的最小字节数,当VTIME参数设置为0时,只有当串口内的数据达到VMIN长度时,read函数才会进行读取操作;
    当时间参数VTIME不为0时,若串口内到达的数据未到达VMIN,read函数将等待VTIME时间之后对数据进行读取;

    另一种监测串口是否有数据到达的函数是select,使用此参数可以在确定串口内有数据时才对串口数据进行读写。

    FD_ZERO(&rfds);
    FD_SET(fd,&rfds);
    timeval timeout;
    timeout.tv_sec = 10;
    timeout.tv_usec = 0;
    retval =select(fd+1,&rfds,NULL,NULL,NULL);

    上述代码通过设置句柄rfds来对fd进行监控,并根据fd的状态,select函数将返回不同的值。其中timeout为超时等待时间,若不希望函数阻塞可以写为:

    retval =select(fd+1,&rfds,NULL,NULL,&timeout);

    读写串口

    读函数:

    res = read(fd,buf,len);

    写函数:

    n = write(fd, "str", len);

    注意,当读写出错是函数将返回值-1。

    关闭串口

    关闭串口简单粗暴:

    close(fd);

    程序实例

    bool connectDevice(){
      fd = open( SerialPort, O_RDWR|/*O_NOCTTY|*/O_NDELAY);
      if (-1 == fd)
      {
         ROS_WARN("Redsky UART:Can't Open Serial Port");
         return(-1);
      }
      // flushing is to be done after opening. This prevents first read and write to be spam'ish.
      tcflush(fd, TCIOFLUSH);
      int n = fcntl(fd, F_GETFL, 0);
      //恢复为阻塞模式
      fcntl(fd, F_SETFL, n & ~O_NDELAY);
      portSet(fd,9600,8,"None","1",false,false);
      connected = true;
      return 1;
    }
    int portSet(int m_fd, int baudrate, int databits, const std::string & parity, const std::string & stop, bool softwareHandshake, bool hardwareHandshake)
    {
       struct termios newtio;
    //  memset(&newtio, 0, sizeof(newtio));
       if (tcgetattr(m_fd, &newtio)!=0)
       {
          //std::cerr<<"tcgetattr() 3 failed"<<std::endl;
          return -1;
       }
       //printf("tcgetattr() 3 success!\n");
    
       speed_t _baud=0;
       switch (baudrate)
       {
      #ifdef B0
         case      0: _baud=B0;     break;
      #endif
    
      #ifdef B50
         case     50: _baud=B50;    break;
      #endif
      #ifdef B75
         case     75: _baud=B75;    break;
      #endif
      #ifdef B110
         case    110: _baud=B110;   break;
      #endif
      #ifdef B134
         case    134: _baud=B134;   break;
      #endif
      #ifdef B150
         case    150: _baud=B150;   break;
      #endif
      #ifdef B200
         case    200: _baud=B200;   break;
      #endif
      #ifdef B300
         case    300: _baud=B300;   break;
      #endif
      #ifdef B600
         case    600: _baud=B600;   break;
      #endif
      #ifdef B1200
         case   1200: _baud=B1200;  break;
      #endif
      #ifdef B1800
         case   1800: _baud=B1800;  break;
      #endif
      #ifdef B2400
         case   2400: _baud=B2400;  break;
      #endif
      #ifdef B4800
         case   4800: _baud=B4800;  break;
      #endif
      #ifdef B7200
         case   7200: _baud=B7200;  break;
      #endif
      #ifdef B9600
         case   9600: _baud=B9600;  break;
      #endif
      #ifdef B14400
         case  14400: _baud=B14400; break;
      #endif
      #ifdef B19200
         case  19200: _baud=B19200; break;
      #endif
      #ifdef B28800
         case  28800: _baud=B28800; break;
      #endif
      #ifdef B38400
         case  38400: _baud=B38400; break;
      #endif
      #ifdef B57600
         case  57600: _baud=B57600; break;
      #endif
      #ifdef B76800
         case  76800: _baud=B76800; break;
      #endif
      #ifdef B115200
         case 115200: _baud=B115200; break;
      #endif
      #ifdef B128000
         case 128000: _baud=B128000; break;
      #endif
      #ifdef B230400
         case 230400: _baud=B230400; break;
      #endif
      #ifdef B460800
         case 460800: _baud=B460800; break;
      #endif
      #ifdef B576000
         case 576000: _baud=B576000; break;
      #endif
      #ifdef B921600
         case 921600: _baud=B921600; break;
      #endif
       default:
    //   case 256000:
    //      _baud=B256000;
          break;
       }
       cfsetospeed(&newtio, (speed_t)_baud);
       cfsetispeed(&newtio, (speed_t)_baud);
    
       /* We generate mark and space parity ourself. */
       if (databits == 7 && (parity=="Mark" || parity == "Space"))
       {
          databits = 8;
       }
       switch (databits)
       {
       case 5:
          newtio.c_cflag = (newtio.c_cflag & ~CSIZE) | CS5;
          break;
       case 6:
          newtio.c_cflag = (newtio.c_cflag & ~CSIZE) | CS6;
          break;
       case 7:
          newtio.c_cflag = (newtio.c_cflag & ~CSIZE) | CS7;
          break;
       case 8:
       default:
          newtio.c_cflag = (newtio.c_cflag & ~CSIZE) | CS8;
          break;
       }
       newtio.c_cflag |= CLOCAL | CREAD;
    
       //parity
       newtio.c_cflag &= ~(PARENB | PARODD);
       if (parity == "Even")
       {
          newtio.c_cflag |= PARENB;
       }
       else if (parity== "Odd")
       {
          newtio.c_cflag |= (PARENB | PARODD);
       }
    
       //hardware handshake
      /*   if (hardwareHandshake)
          newtio.c_cflag |= CRTSCTS;
       else
          newtio.c_cflag &= ~CRTSCTS;*/
       newtio.c_cflag &= ~CRTSCTS;
    
       //stopbits
       if (stop=="2")
       {
          newtio.c_cflag |= CSTOPB;
       }
       else
       {
          newtio.c_cflag &= ~CSTOPB;
       }
    
       //   newtio.c_iflag=IGNPAR | IGNBRK;
       newtio.c_iflag=IGNBRK;
       //   newtio.c_iflag=IGNPAR;
    
       //software handshake
       if (softwareHandshake)
       {
          newtio.c_iflag |= IXON | IXOFF;
       }
       else
       {
          newtio.c_iflag &= ~(IXON|IXOFF|IXANY);
       }
    
       newtio.c_lflag=0;
       newtio.c_oflag=0;
    
       newtio.c_cc[VTIME]=1;
       newtio.c_cc[VMIN]=60;
    
    //   tcflush(m_fd, TCIFLUSH);
       if (tcsetattr(m_fd, TCSANOW, &newtio)!=0)
       {
          std::cerr<<"tcsetattr() 1 failed"<<std::endl;
       }
    
       int mcs=0;
       ioctl(m_fd, TIOCMGET, &mcs);
       mcs |= TIOCM_RTS;
       ioctl(m_fd, TIOCMSET, &mcs);
    
       if (tcgetattr(m_fd, &newtio)!=0)
       {
          //std::cerr<<"tcgetattr() 4 failed"<<std::endl;
       }
    
       //hardware handshake
       if (hardwareHandshake)
       {
          newtio.c_cflag |= CRTSCTS;
       }
       else
       {
          newtio.c_cflag &= ~CRTSCTS;
       }
    /*  if (on)
         newtio.c_cflag |= CRTSCTS;
      else
         newtio.c_cflag &= ~CRTSCTS;*/
       if (tcsetattr(m_fd, TCSANOW, &newtio)!=0)
       {
          //std::cerr<<"tcsetattr() 2 failed"<<std::endl;
       }
       //printf("tcsetattr() 2 success!\n");
       return 1;
    }
    
    int readRev(char* revBuf){
      //使用select设置阻塞时间
      fd_set rfds;
      FD_ZERO(&rfds);
      FD_SET(fd,&rfds);
      timeval timeout;
      timeout.tv_sec = 1;  //秒
      timeout.tv_usec = 0;  //微秒
      //int retval = select(fd+1, &rfds, NULL, NULL, &timeout);
      int retval = select(fd+1, &rfds, NULL, NULL, &timeout);
    
      if(retval <= 0){
        ROS_WARN("No data receive from port, select error");
        return -1;//"noData";
      }
      else{
        int len = read(fd, revBuf, MAXBUF);
      }
    }
    展开全文
  • C++串口编程实例

    2020-09-10 16:21:55
    在windows程序设计与开发过程中,特别是涉及到开发嵌入式软硬件系统时,往往会涉及到串口编程。网上以及一些书籍上讲解windows下的串口编程知识也挺多的,但我个人觉得,看完书上的知识点有时依然不知道该如何下手...

    在windows程序设计与开发过程中,特别是涉及到开发嵌入式软硬件系统时,往往会涉及到串口编程。网上以及一些书籍上讲解windows下的串口编程知识也挺多的,但我个人觉得,看完书上的知识点有时依然不知道该如何下手开始自己的程序设计和代码编写,许多知识如果能结合着详细的例子往往能够帮助我们学习得更快,所以,在此,我专门为串口编程初学者设计了一个详细的例子,供大家参考和学习。
       
    下面我将自己用C++编写的串口通信的例子贴出来,其特点如下:
       
    1. 本例子使用了比较规范的软件设计方法,类的设计具有比较好的可扩展性和移植性、代码的注释采用doxgen支持的javaDoc风格。
    2. 为了能方便初学者更快地了解和入门,几乎每一行代码都加上了详细的注释,对于注释中如果依然有不清楚的概念,相信你通过百度和google一定能找到答案。
    3. 本例子设计的串口操作类可以直接移植到其他的工程中去,大家也可以根据自己的需要添加其他的接口。
    4. 本例子只实现了串口数据的基本收发功能,其实为了保证串口数据传输的正确性,往往需要设计一些串口通信协议,协议的设计有待你自己完成,如果以后有时间,我也会尝试提供一种比较基本的串口通信协议设计案例给大家学习。
    5. 关于本程序的验证方法,可以使用虚拟串口软件VSPM和串口调试助手进行程序的测试与验证,上述两个软件的使用方法请参考:http://ticktick.blog.51cto.com/823160/285610

     

    下面即为例子工程的三个文件,SerialPort.h、SerialPort.cpp、maincpp

     

    附件中是工程文件,需要使用vs2008打开

         

    
     
    1. //  
    2. /// COPYRIGHT NOTICE  
    3. /// Copyright (c) 2009, 华中科技大学tickTick Group  (版权声明)  
    4. /// All rights reserved.  
    5. ///   
    6. /// @file    SerialPort.h    
    7. /// @brief   串口通信类头文件  
    8. ///  
    9. /// 本文件完成串口通信类的声明  
    10. ///  
    11. /// @version 1.0     
    12. /// @author  卢俊   
    13. /// @E-mail:lujun.hust@gmail.com  
    14. /// @date    2010/03/19  
    15. ///  
    16. ///  修订说明:  
    17. //  
    18.  
    19. #ifndef SERIALPORT_H_  
    20. #define SERIALPORT_H_  
    21.  
    22. #include <Windows.h>  
    23.  
    24. /** 串口通信类  
    25.  *     
    26.  *  本类实现了对串口的基本操作  
    27.  *  例如监听发到指定串口的数据、发送指定数据到串口  
    28.  */ 
    29. class CSerialPort  
    30. {  
    31. public:  
    32.     CSerialPort(void);  
    33.     ~CSerialPort(void);  
    34.  
    35. public:  
    36.       
    37.     /** 初始化串口函数  
    38.      *  
    39.      *  @param:  UINT portNo 串口编号,默认值为1,即COM1,注意,尽量不要大于9  
    40.      *  @param:  UINT baud   波特率,默认为9600  
    41.      *  @param:  char parity 是否进行奇偶校验,'Y'表示需要奇偶校验,'N'表示不需要奇偶校验  
    42.      *  @param:  UINT databits 数据位的个数,默认值为8个数据位  
    43.      *  @param:  UINT stopsbits 停止位使用格式,默认值为1  
    44.      *  @param:  DWORD dwCommEvents 默认为EV_RXCHAR,即只要收发任意一个字符,则产生一个事件  
    45.      *  @return: bool  初始化是否成功  
    46.      *  @note:   在使用其他本类提供的函数前,请先调用本函数进行串口的初始化  
    47.      *       \n本函数提供了一些常用的串口参数设置,若需要自行设置详细的DCB参数,可使用重载函数  
    48.      *           \n本串口类析构时会自动关闭串口,无需额外执行关闭串口  
    49.      *  @see:      
    50.      */ 
    51.     bool InitPort( UINT  portNo = 1,UINT  baud = CBR_9600,char  parity = 'N',UINT  databits = 8, UINT  stopsbits = 1,DWORD dwCommEvents = EV_RXCHAR);  
    52.  
    53.     /** 串口初始化函数  
    54.      *  
    55.      *  本函数提供直接根据DCB参数设置串口参数  
    56.      *  @param:  UINT portNo  
    57.      *  @param:  const LPDCB & plDCB  
    58.      *  @return: bool  初始化是否成功  
    59.      *  @note:   本函数提供用户自定义地串口初始化参数  
    60.      *  @see:      
    61.      */ 
    62.     bool InitPort( UINT  portNo ,const LPDCB& plDCB );  
    63.  
    64.     /** 开启监听线程  
    65.      *  
    66.      *  本监听线程完成对串口数据的监听,并将接收到的数据打印到屏幕输出  
    67.      *  @return: bool  操作是否成功  
    68.      *  @note:   当线程已经处于开启状态时,返回flase  
    69.      *  @see:      
    70.      */ 
    71.     bool OpenListenThread();  
    72.  
    73.     /** 关闭监听线程  
    74.      *  
    75.      *    
    76.      *  @return: bool  操作是否成功  
    77.      *  @note:   调用本函数后,监听串口的线程将会被关闭  
    78.      *  @see:      
    79.      */ 
    80.     bool CloseListenTread();  
    81.  
    82.     /** 向串口写数据  
    83.      *  
    84.      *  将缓冲区中的数据写入到串口  
    85.      *  @param:  unsigned char * pData 指向需要写入串口的数据缓冲区  
    86.      *  @param:  unsigned int length 需要写入的数据长度  
    87.      *  @return: bool  操作是否成功  
    88.      *  @note:   length不要大于pData所指向缓冲区的大小  
    89.      *  @see:      
    90.      */ 
    91.     bool WriteData(unsigned char* pData, unsigned int length);  
    92.  
    93.     /** 获取串口缓冲区中的字节数  
    94.      *  
    95.      *    
    96.      *  @return: UINT  操作是否成功  
    97.      *  @note:   当串口缓冲区中无数据时,返回0  
    98.      *  @see:      
    99.      */ 
    100.     UINT GetBytesInCOM();  
    101.  
    102.     /** 读取串口接收缓冲区中一个字节的数据  
    103.      *  
    104.      *    
    105.      *  @param:  char & cRecved 存放读取数据的字符变量  
    106.      *  @return: bool  读取是否成功  
    107.      *  @note:     
    108.      *  @see:      
    109.      */ 
    110.     bool ReadChar(char &cRecved);  
    111.  
    112. private:  
    113.  
    114.     /** 打开串口  
    115.      *  
    116.      *    
    117.      *  @param:  UINT portNo 串口设备号  
    118.      *  @return: bool  打开是否成功  
    119.      *  @note:     
    120.      *  @see:      
    121.      */ 
    122.     bool openPort( UINT  portNo );  
    123.  
    124.     /** 关闭串口  
    125.      *  
    126.      *    
    127.      *  @return: void  操作是否成功  
    128.      *  @note:     
    129.      *  @see:      
    130.      */ 
    131.     void ClosePort();  
    132.       
    133.     /** 串口监听线程  
    134.      *  
    135.      *  监听来自串口的数据和信息  
    136.      *  @param:  void * pParam 线程参数  
    137.      *  @return: UINT WINAPI 线程返回值  
    138.      *  @note:     
    139.      *  @see:      
    140.      */ 
    141.     static UINT WINAPI ListenThread(void* pParam);  
    142.  
    143. private:  
    144.  
    145.     /** 串口句柄 */   
    146.     HANDLE  m_hComm;  
    147.  
    148.     /** 线程退出标志变量 */   
    149.     static bool s_bExit;  
    150.  
    151.     /** 线程句柄 */   
    152.     volatile HANDLE    m_hListenThread;  
    153.  
    154.     /** 同步互斥,临界区保护 */   
    155.     CRITICAL_SECTION   m_csCommunicationSync;       //!< 互斥操作串口  
    156.  
    157. };  
    158.  
    159. #endif //SERIALPORT_H_ 
    
     
    1. //  
    2. /// COPYRIGHT NOTICE  
    3. /// Copyright (c) 2009, 华中科技大学tickTick Group  (版权声明)  
    4. /// All rights reserved.  
    5. ///   
    6. /// @file    SerialPort.cpp    
    7. /// @brief   串口通信类的实现文件  
    8. ///  
    9. /// 本文件为串口通信类的实现代码  
    10. ///  
    11. /// @version 1.0     
    12. /// @author  卢俊    
    13. /// @E-mail:lujun.hust@gmail.com  
    14. /// @date    2010/03/19  
    15. ///   
    16. ///  
    17. ///  修订说明:  
    18. //  
    19.  
    20. #include "StdAfx.h"  
    21. #include "SerialPort.h"  
    22. #include <process.h>  
    23. #include <iostream>  
    24.  
    25. /** 线程退出标志 */   
    26. bool CSerialPort::s_bExit = false;  
    27. /** 当串口无数据时,sleep至下次查询间隔的时间,单位:秒 */   
    28. const UINT SLEEP_TIME_INTERVAL = 5;  
    29.  
    30. CSerialPort::CSerialPort(void)  
    31. : m_hListenThread(INVALID_HANDLE_VALUE)  
    32. {  
    33.     m_hComm = INVALID_HANDLE_VALUE;  
    34.     m_hListenThread = INVALID_HANDLE_VALUE;  
    35.  
    36.     InitializeCriticalSection(&m_csCommunicationSync);  
    37.  
    38. }  
    39.  
    40. CSerialPort::~CSerialPort(void)  
    41. {  
    42.     CloseListenTread();  
    43.     ClosePort();  
    44.     DeleteCriticalSection(&m_csCommunicationSync);  
    45. }  
    46.  
    47. bool CSerialPort::InitPort( UINT portNo /*= 1*/,UINT baud /*= CBR_9600*/,char parity /*= 'N'*/,  
    48.                             UINT databits /*= 8*/, UINT stopsbits /*= 1*/,DWORD dwCommEvents /*= EV_RXCHAR*/ )  
    49. {  
    50.  
    51.     /** 临时变量,将制定参数转化为字符串形式,以构造DCB结构 */   
    52.     char szDCBparam[50];  
    53.     sprintf_s(szDCBparam, "baud=%d parity=%c data=%d stop=%d", baud, parity, databits, stopsbits);  
    54.  
    55.     /** 打开指定串口,该函数内部已经有临界区保护,上面请不要加保护 */   
    56.     if (!openPort(portNo))  
    57.     {  
    58.         return false;  
    59.     }  
    60.  
    61.     /** 进入临界段 */   
    62.     EnterCriticalSection(&m_csCommunicationSync);  
    63.  
    64.     /** 是否有错误发生 */   
    65.     BOOL bIsSuccess = TRUE;  
    66.  
    67.     /** 在此可以设置输入输出的缓冲区大小,如果不设置,则系统会设置默认值.  
    68.      *  自己设置缓冲区大小时,要注意设置稍大一些,避免缓冲区溢出  
    69.      */ 
    70.     /*if (bIsSuccess )  
    71.     {  
    72.         bIsSuccess = SetupComm(m_hComm,10,10);  
    73.     }*/ 
    74.  
    75.     /** 设置串口的超时时间,均设为0,表示不使用超时限制 */ 
    76.     COMMTIMEOUTS  CommTimeouts;  
    77.     CommTimeouts.ReadIntervalTimeout         = 0;  
    78.     CommTimeouts.ReadTotalTimeoutMultiplier  = 0;  
    79.     CommTimeouts.ReadTotalTimeoutConstant    = 0;  
    80.     CommTimeouts.WriteTotalTimeoutMultiplier = 0;  
    81.     CommTimeouts.WriteTotalTimeoutConstant   = 0;   
    82.     if ( bIsSuccess)  
    83.     {  
    84.         bIsSuccess = SetCommTimeouts(m_hComm, &CommTimeouts);  
    85.     }  
    86.  
    87.     DCB  dcb;  
    88.     if ( bIsSuccess )  
    89.     {  
    90.         // 将ANSI字符串转换为UNICODE字符串  
    91.         DWORD dwNum = MultiByteToWideChar (CP_ACP, 0, szDCBparam, -1, NULL, 0);  
    92.         wchar_t *pwText = new wchar_t[dwNum] ;  
    93.         if (!MultiByteToWideChar (CP_ACP, 0, szDCBparam, -1, pwText, dwNum))  
    94.         {  
    95.             bIsSuccess = TRUE;  
    96.         }  
    97.  
    98.         /** 获取当前串口配置参数,并且构造串口DCB参数 */   
    99.         bIsSuccess = GetCommState(m_hComm, &dcb) && BuildCommDCB(pwText, &dcb) ;  
    100.         /** 开启RTS flow控制 */   
    101.         dcb.fRtsControl = RTS_CONTROL_ENABLE;   
    102.  
    103.         /** 释放内存空间 */   
    104.         delete [] pwText;  
    105.     }  
    106.  
    107.     if ( bIsSuccess )  
    108.     {  
    109.         /** 使用DCB参数配置串口状态 */   
    110.         bIsSuccess = SetCommState(m_hComm, &dcb);  
    111.     }  
    112.           
    113.     /**  清空串口缓冲区 */ 
    114.     PurgeComm(m_hComm, PURGE_RXCLEAR | PURGE_TXCLEAR | PURGE_RXABORT | PURGE_TXABORT);  
    115.  
    116.     /** 离开临界段 */   
    117.     LeaveCriticalSection(&m_csCommunicationSync);  
    118.  
    119.     return bIsSuccess==TRUE;  
    120. }  
    121.  
    122. bool CSerialPort::InitPort( UINT portNo ,const LPDCB& plDCB )  
    123. {  
    124.     /** 打开指定串口,该函数内部已经有临界区保护,上面请不要加保护 */   
    125.     if (!openPort(portNo))  
    126.     {  
    127.         return false;  
    128.     }  
    129.       
    130.     /** 进入临界段 */   
    131.     EnterCriticalSection(&m_csCommunicationSync);  
    132.  
    133.     /** 配置串口参数 */   
    134.     if (!SetCommState(m_hComm, plDCB))  
    135.     {  
    136.         return false;  
    137.     }  
    138.  
    139.     /**  清空串口缓冲区 */ 
    140.     PurgeComm(m_hComm, PURGE_RXCLEAR | PURGE_TXCLEAR | PURGE_RXABORT | PURGE_TXABORT);  
    141.  
    142.     /** 离开临界段 */   
    143.     LeaveCriticalSection(&m_csCommunicationSync);  
    144.  
    145.     return true;  
    146. }  
    147.  
    148. void CSerialPort::ClosePort()  
    149. {  
    150.     /** 如果有串口被打开,关闭它 */ 
    151.     if( m_hComm != INVALID_HANDLE_VALUE )  
    152.     {  
    153.         CloseHandle( m_hComm );  
    154.         m_hComm = INVALID_HANDLE_VALUE;  
    155.     }  
    156. }  
    157.  
    158. bool CSerialPort::openPort( UINT portNo )  
    159. {  
    160.     /** 进入临界段 */   
    161.     EnterCriticalSection(&m_csCommunicationSync);  
    162.  
    163.     /** 把串口的编号转换为设备名 */   
    164.     char szPort[50];  
    165.     sprintf_s(szPort, "COM%d", portNo);  
    166.  
    167.     /** 打开指定的串口 */   
    168.     m_hComm = CreateFileA(szPort, /** 设备名,COM1,COM2等 */   
    169.               GENERIC_READ | GENERIC_WRITE, /** 访问模式,可同时读写 */     
    170.               0,                           /** 共享模式,0表示不共享 */   
    171.               NULL,                         /** 安全性设置,一般使用NULL */   
    172.               OPEN_EXISTING,                /** 该参数表示设备必须存在,否则创建失败 */   
    173.               0,      
    174.               0);      
    175.  
    176.     /** 如果打开失败,释放资源并返回 */   
    177.     if (m_hComm == INVALID_HANDLE_VALUE)  
    178.     {  
    179.         LeaveCriticalSection(&m_csCommunicationSync);  
    180.         return false;  
    181.     }  
    182.  
    183.     /** 退出临界区 */   
    184.     LeaveCriticalSection(&m_csCommunicationSync);  
    185.  
    186.     return true;  
    187. }  
    188.  
    189. bool CSerialPort::OpenListenThread()  
    190. {  
    191.     /** 检测线程是否已经开启了 */   
    192.     if (m_hListenThread != INVALID_HANDLE_VALUE)  
    193.     {  
    194.         /** 线程已经开启 */   
    195.         return false;  
    196.     }  
    197.  
    198.     s_bExit = false;  
    199.     /** 线程ID */   
    200.     UINT threadId;  
    201.     /** 开启串口数据监听线程 */   
    202.     m_hListenThread = (HANDLE)_beginthreadex(NULL, 0, ListenThread, this, 0, &threadId);  
    203.     if (!m_hListenThread)  
    204.     {  
    205.         return false;  
    206.     }  
    207.     /** 设置线程的优先级,高于普通线程 */   
    208.     if (!SetThreadPriority(m_hListenThread, THREAD_PRIORITY_ABOVE_NORMAL))  
    209.     {  
    210.         return false;  
    211.     }  
    212.  
    213.     return true;  
    214. }  
    215.  
    216. bool CSerialPort::CloseListenTread()  
    217. {     
    218.     if (m_hListenThread != INVALID_HANDLE_VALUE)  
    219.     {  
    220.         /** 通知线程退出 */   
    221.         s_bExit = true;  
    222.  
    223.         /** 等待线程退出 */   
    224.         Sleep(10);  
    225.  
    226.         /** 置线程句柄无效 */   
    227.         CloseHandle( m_hListenThread );  
    228.         m_hListenThread = INVALID_HANDLE_VALUE;  
    229.     }  
    230.     return true;  
    231. }  
    232.  
    233. UINT CSerialPort::GetBytesInCOM()  
    234. {  
    235.     DWORD dwError = 0;  /** 错误码 */   
    236.     COMSTAT  comstat;   /** COMSTAT结构体,记录通信设备的状态信息 */   
    237.     memset(&comstat, 0, sizeof(COMSTAT));  
    238.  
    239.     UINT BytesInQue = 0;  
    240.     /** 在调用ReadFile和WriteFile之前,通过本函数清除以前遗留的错误标志 */   
    241.     if ( ClearCommError(m_hComm, &dwError, &comstat) )  
    242.     {  
    243.         BytesInQue = comstat.cbInQue; /** 获取在输入缓冲区中的字节数 */   
    244.     }  
    245.  
    246.     return BytesInQue;  
    247. }  
    248.  
    249. UINT WINAPI CSerialPort::ListenThread( void* pParam )  
    250. {  
    251.     /** 得到本类的指针 */   
    252.     CSerialPort *pSerialPort = reinterpret_cast<CSerialPort*>(pParam);  
    253.  
    254.     // 线程循环,轮询方式读取串口数据  
    255.     while (!pSerialPort->s_bExit)   
    256.     {  
    257.         UINT BytesInQue = pSerialPort->GetBytesInCOM();  
    258.         /** 如果串口输入缓冲区中无数据,则休息一会再查询 */   
    259.         if ( BytesInQue == 0 )  
    260.         {  
    261.             Sleep(SLEEP_TIME_INTERVAL);  
    262.             continue;  
    263.         }  
    264.  
    265.         /** 读取输入缓冲区中的数据并输出显示 */ 
    266.         char cRecved = 0x00;  
    267.         do 
    268.         {  
    269.             cRecved = 0x00;  
    270.             if(pSerialPort->ReadChar(cRecved) == true)  
    271.             {  
    272.                 std::cout << cRecved ;   
    273.                 continue;  
    274.             }  
    275.         }while(--BytesInQue);  
    276.     }  
    277.  
    278.     return 0;  
    279. }  
    280.  
    281. bool CSerialPort::ReadChar( char &cRecved )  
    282. {  
    283.     BOOL  bResult     = TRUE;  
    284.     DWORD BytesRead   = 0;  
    285.     if(m_hComm == INVALID_HANDLE_VALUE)  
    286.     {  
    287.         return false;  
    288.     }  
    289.  
    290.     /** 临界区保护 */   
    291.     EnterCriticalSection(&m_csCommunicationSync);  
    292.  
    293.     /** 从缓冲区读取一个字节的数据 */   
    294.     bResult = ReadFile(m_hComm, &cRecved, 1, &BytesRead, NULL);  
    295.     if ((!bResult))  
    296.     {   
    297.         /** 获取错误码,可以根据该错误码查出错误原因 */   
    298.         DWORD dwError = GetLastError();  
    299.  
    300.         /** 清空串口缓冲区 */   
    301.         PurgeComm(m_hComm, PURGE_RXCLEAR | PURGE_RXABORT);  
    302.         LeaveCriticalSection(&m_csCommunicationSync);  
    303.  
    304.         return false;  
    305.     }  
    306.  
    307.     /** 离开临界区 */   
    308.     LeaveCriticalSection(&m_csCommunicationSync);  
    309.  
    310.     return (BytesRead == 1);  
    311.  
    312. }  
    313.  
    314. bool CSerialPort::WriteData( unsigned char* pData, unsigned int length )  
    315. {  
    316.     BOOL   bResult     = TRUE;  
    317.     DWORD  BytesToSend = 0;  
    318.     if(m_hComm == INVALID_HANDLE_VALUE)  
    319.     {  
    320.         return false;  
    321.     }  
    322.  
    323.     /** 临界区保护 */   
    324.     EnterCriticalSection(&m_csCommunicationSync);  
    325.  
    326.     /** 向缓冲区写入指定量的数据 */   
    327.     bResult = WriteFile(m_hComm, pData, length, &BytesToSend, NULL);  
    328.     if (!bResult)    
    329.     {  
    330.         DWORD dwError = GetLastError();  
    331.         /** 清空串口缓冲区 */   
    332.         PurgeComm(m_hComm, PURGE_RXCLEAR | PURGE_RXABORT);  
    333.         LeaveCriticalSection(&m_csCommunicationSync);  
    334.  
    335.         return false;  
    336.     }  
    337.  
    338.     /** 离开临界区 */   
    339.     LeaveCriticalSection(&m_csCommunicationSync);  
    340.  
    341.     return true;  
    342. }  
    
     
    1. // main.cpp : Defines the entry point for the console application.  
    2. //  
    3.  
    4. #include "stdafx.h"  
    5. #include "SerialPort.h"  
    6. #include <iostream>  
    7.  
    8. int _tmain(int argc, _TCHAR* argv[])  
    9. {  
    10.  
    11.     CSerialPort mySerialPort;  
    12.  
    13.     if (!mySerialPort.InitPort(2))  
    14.     {  
    15.         std::cout << "initPort fail !" << std::endl;  
    16.     }  
    17.     else 
    18.     {  
    19.         std::cout << "initPort success !" << std::endl;  
    20.     }  
    21.  
    22.     if (!mySerialPort.OpenListenThread())  
    23.     {  
    24.         std::cout << "OpenListenThread fail !" << std::endl;  
    25.     }  
    26.     else 
    27.     {  
    28.         std::cout << "OpenListenThread success !" << std::endl;  
    29.     }  
    30.  
    31.     int temp;  
    32.     std::cin >> temp;  
    33.  
    34.     return 0;  
    35. }  
    36.  

    https://www.imdb.com/list/ls083599194/
    https://www.imdb.com/list/ls083599194/?ref_=otl_7
    https://m.imdb.com/list/ls083599194/
    https://www.imdb.com/list/ls083599194/?ref_=otl_9b
    https://www.imdb.com/list/ls083599194/?ref_=otl_1
    https://www.imdb.com/list/ls083599194/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599194/?bvhhr=9b
    https://www.imdb.com/list/ls083599194/?mode=desktop
    https://www.imdb.com/list/ls083599185/
    https://www.imdb.com/list/ls083599185/?ref_=otl_B
    https://m.imdb.com/list/ls083599185/
    https://www.imdb.com/list/ls083599185/?ref_=otl_59
    https://www.imdb.com/list/ls083599185/?ref_=otl_1
    https://www.imdb.com/list/ls083599185/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599185/?nddrn=59
    https://www.imdb.com/list/ls083599185/?mode=desktop
    https://www.imdb.com/list/ls083599184/
    https://www.imdb.com/list/ls083599184/?ref_=otl_o
    https://m.imdb.com/list/ls083599184/
    https://www.imdb.com/list/ls083599184/?ref_=otl_O2
    https://www.imdb.com/list/ls083599184/?ref_=otl_8
    https://www.imdb.com/list/ls083599184/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599184/?qqoqq=O2
    https://www.imdb.com/list/ls083599184/?mode=desktop
    https://www.imdb.com/list/ls083599306/
    https://www.imdb.com/list/ls083599306/?ref_=otl_J
    https://m.imdb.com/list/ls083599306/
    https://www.imdb.com/list/ls083599306/?ref_=otl_3u
    https://www.imdb.com/list/ls083599306/?ref_=otl_0
    https://www.imdb.com/list/ls083599306/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599306/?fqjfj=3u
    https://www.imdb.com/list/ls083599306/?mode=desktop
    https://www.imdb.com/list/ls083599352/
    https://www.imdb.com/list/ls083599352/?ref_=otl_9
    https://m.imdb.com/list/ls083599352/
    https://www.imdb.com/list/ls083599352/?ref_=otl_Bv
    https://www.imdb.com/list/ls083599352/?ref_=otl_5
    https://www.imdb.com/list/ls083599352/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599352/?hzrvr=Bv
    https://www.imdb.com/list/ls083599352/?mode=desktop
    https://www.imdb.com/list/ls083599371/
    https://www.imdb.com/list/ls083599371/?ref_=otl_F
    https://m.imdb.com/list/ls083599371/
    https://www.imdb.com/list/ls083599371/?ref_=otl_R7
    https://www.imdb.com/list/ls083599371/?ref_=otl_3
    https://www.imdb.com/list/ls083599371/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599371/?vzhft=R7
    https://www.imdb.com/list/ls083599371/?mode=desktop
    https://www.imdb.com/list/ls083599319/
    https://www.imdb.com/list/ls083599319/?ref_=otl_p
    https://m.imdb.com/list/ls083599319/
    https://www.imdb.com/list/ls083599319/?ref_=otl_73
    https://www.imdb.com/list/ls083599319/?ref_=otl_5
    https://www.imdb.com/list/ls083599319/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599319/?jvbjh=73
    https://www.imdb.com/list/ls083599319/?mode=desktop
    https://www.imdb.com/list/ls083599333/
    https://www.imdb.com/list/ls083599333/?ref_=otl_H
    https://m.imdb.com/list/ls083599333/
    https://www.imdb.com/list/ls083599333/?ref_=otl_tD
    https://www.imdb.com/list/ls083599333/?ref_=otl_5
    https://www.imdb.com/list/ls083599333/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599333/?pbxrf=tD
    https://www.imdb.com/list/ls083599333/?mode=desktop
    https://www.imdb.com/list/ls083599360/
    https://www.imdb.com/list/ls083599360/?ref_=otl_R
    https://m.imdb.com/list/ls083599360/
    https://www.imdb.com/list/ls083599360/?ref_=otl_J7
    https://www.imdb.com/list/ls083599360/?ref_=otl_1
    https://www.imdb.com/list/ls083599360/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599360/?xvdrf=J7
    https://www.imdb.com/list/ls083599360/?mode=desktop
    https://www.imdb.com/list/ls083599362/
    https://www.imdb.com/list/ls083599362/?ref_=otl_6
    https://m.imdb.com/list/ls083599362/
    https://www.imdb.com/list/ls083599362/?ref_=otl_Ii
    https://www.imdb.com/list/ls083599362/?ref_=otl_8
    https://www.imdb.com/list/ls083599362/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599362/?okowe=Ii
    https://www.imdb.com/list/ls083599362/?mode=desktop
    https://www.imdb.com/list/ls083599323/
    https://www.imdb.com/list/ls083599323/?ref_=otl_t
    https://m.imdb.com/list/ls083599323/
    https://www.imdb.com/list/ls083599323/?ref_=otl_z1
    https://www.imdb.com/list/ls083599323/?ref_=otl_1
    https://www.imdb.com/list/ls083599323/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599323/?zfbzz=z1
    https://www.imdb.com/list/ls083599323/?mode=desktop
    https://www.imdb.com/list/ls083599341/
    https://www.imdb.com/list/ls083599341/?ref_=otl_P
    https://m.imdb.com/list/ls083599341/
    https://www.imdb.com/list/ls083599341/?ref_=otl_j3
    https://www.imdb.com/list/ls083599341/?ref_=otl_5
    https://www.imdb.com/list/ls083599341/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599341/?hrxpx=j3
    https://www.imdb.com/list/ls083599341/?mode=desktop
    https://www.imdb.com/list/ls083599395/
    https://www.imdb.com/list/ls083599395/?ref_=otl_1
    https://m.imdb.com/list/ls083599395/
    https://www.imdb.com/list/ls083599395/?ref_=otl_FR
    https://www.imdb.com/list/ls083599395/?ref_=otl_3
    https://www.imdb.com/list/ls083599395/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599395/?zbdlv=FR
    https://www.imdb.com/list/ls083599395/?mode=desktop
    https://www.imdb.com/list/ls083599398/
    https://www.imdb.com/list/ls083599398/?ref_=otl_s
    https://m.imdb.com/list/ls083599398/
    https://www.imdb.com/list/ls083599398/?ref_=otl_42
    https://www.imdb.com/list/ls083599398/?ref_=otl_2
    https://www.imdb.com/list/ls083599398/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599398/?asoow=42
    https://www.imdb.com/list/ls083599398/?mode=desktop
    https://www.imdb.com/list/ls083599383/
    https://www.imdb.com/list/ls083599383/?ref_=otl_C
    https://m.imdb.com/list/ls083599383/
    https://www.imdb.com/list/ls083599383/?ref_=otl_i0
    https://www.imdb.com/list/ls083599383/?ref_=otl_4
    https://www.imdb.com/list/ls083599383/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599383/?esiqk=i0
    https://www.imdb.com/list/ls083599383/?mode=desktop
    https://www.imdb.com/list/ls083599607/
    https://www.imdb.com/list/ls083599607/?ref_=otl_9
    https://m.imdb.com/list/ls083599607/
    https://www.imdb.com/list/ls083599607/?ref_=otl_rZ
    https://www.imdb.com/list/ls083599607/?ref_=otl_3
    https://www.imdb.com/list/ls083599607/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599607/?fthpp=rZ
    https://www.imdb.com/list/ls083599607/?mode=desktop
    https://www.imdb.com/list/ls083599609/
    https://www.imdb.com/list/ls083599609/?ref_=otl_i
    https://m.imdb.com/list/ls083599609/
    https://www.imdb.com/list/ls083599609/?ref_=otl_E6
    https://www.imdb.com/list/ls083599609/?ref_=otl_0
    https://www.imdb.com/list/ls083599609/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599609/?cwmqw=E6
    https://www.imdb.com/list/ls083599609/?mode=desktop
    https://www.imdb.com/list/ls083599658/
    https://www.imdb.com/list/ls083599658/?ref_=otl_7
    https://m.imdb.com/list/ls083599658/
    https://www.imdb.com/list/ls083599658/?ref_=otl_51
    https://www.imdb.com/list/ls083599658/?ref_=otl_5
    https://www.imdb.com/list/ls083599658/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599658/?bfhlb=51
    https://www.imdb.com/list/ls083599658/?mode=desktop
    https://www.imdb.com/list/ls083599672/
    https://www.imdb.com/list/ls083599672/?ref_=otl_8
    https://m.imdb.com/list/ls083599672/
    https://www.imdb.com/list/ls083599672/?ref_=otl_qK
    https://www.imdb.com/list/ls083599672/?ref_=otl_4
    https://www.imdb.com/list/ls083599672/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599672/?cyyiq=qK
    https://www.imdb.com/list/ls083599672/?mode=desktop
    https://www.imdb.com/list/ls083599611/
    https://www.imdb.com/list/ls083599611/?ref_=otl_f
    https://m.imdb.com/list/ls083599611/
    https://www.imdb.com/list/ls083599611/?ref_=otl_hx
    https://www.imdb.com/list/ls083599611/?ref_=otl_1
    https://www.imdb.com/list/ls083599611/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599611/?nznvb=hx
    https://www.imdb.com/list/ls083599611/?mode=desktop
    https://www.imdb.com/list/ls083599618/
    https://www.imdb.com/list/ls083599618/?ref_=otl_k
    https://m.imdb.com/list/ls083599618/
    https://www.imdb.com/list/ls083599618/?ref_=otl_Qs
    https://www.imdb.com/list/ls083599618/?ref_=otl_8
    https://www.imdb.com/list/ls083599618/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599618/?yyscu=Qs
    https://www.imdb.com/list/ls083599618/?mode=desktop
    https://www.imdb.com/list/ls083599632/
    https://www.imdb.com/list/ls083599632/?ref_=otl_Q
    https://m.imdb.com/list/ls083599632/
    https://www.imdb.com/list/ls083599632/?ref_=otl_ao
    https://www.imdb.com/list/ls083599632/?ref_=otl_2
    https://www.imdb.com/list/ls083599632/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599632/?ugcsi=ao
    https://www.imdb.com/list/ls083599632/?mode=desktop
    https://www.imdb.com/list/ls083599661/
    https://www.imdb.com/list/ls083599661/?ref_=otl_e
    https://m.imdb.com/list/ls083599661/
    https://www.imdb.com/list/ls083599661/?ref_=otl_68
    https://www.imdb.com/list/ls083599661/?ref_=otl_6
    https://www.imdb.com/list/ls083599661/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599661/?uaioo=68
    https://www.imdb.com/list/ls083599661/?mode=desktop
    https://www.imdb.com/list/ls083599625/
    https://www.imdb.com/list/ls083599625/?ref_=otl_1
    https://m.imdb.com/list/ls083599625/
    https://www.imdb.com/list/ls083599625/?ref_=otl_N7
    https://www.imdb.com/list/ls083599625/?ref_=otl_5
    https://www.imdb.com/list/ls083599625/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599625/?fjtbl=N7
    https://www.imdb.com/list/ls083599625/?mode=desktop
    https://www.imdb.com/list/ls083599622/
    https://www.imdb.com/list/ls083599622/?ref_=otl_8
    https://m.imdb.com/list/ls083599622/
    https://www.imdb.com/list/ls083599622/?ref_=otl_Gc
    https://www.imdb.com/list/ls083599622/?ref_=otl_0
    https://www.imdb.com/list/ls083599622/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599622/?ymiqo=Gc
    https://www.imdb.com/list/ls083599622/?mode=desktop
    https://www.imdb.com/list/ls083599641/
    https://www.imdb.com/list/ls083599641/?ref_=otl_1
    https://m.imdb.com/list/ls083599641/
    https://www.imdb.com/list/ls083599641/?ref_=otl_d9
    https://www.imdb.com/list/ls083599641/?ref_=otl_9
    https://www.imdb.com/list/ls083599641/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599641/?rjnrj=d9
    https://www.imdb.com/list/ls083599641/?mode=desktop
    https://www.imdb.com/list/ls083599699/
    https://www.imdb.com/list/ls083599699/?ref_=otl_f
    https://m.imdb.com/list/ls083599699/
    https://www.imdb.com/list/ls083599699/?ref_=otl_P5
    https://www.imdb.com/list/ls083599699/?ref_=otl_9
    https://www.imdb.com/list/ls083599699/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599699/?dvzrr=P5
    https://www.imdb.com/list/ls083599699/?mode=desktop
    https://www.imdb.com/list/ls083599687/
    https://www.imdb.com/list/ls083599687/?ref_=otl_M
    https://m.imdb.com/list/ls083599687/
    https://www.imdb.com/list/ls083599687/?ref_=otl_Wi
    https://www.imdb.com/list/ls083599687/?ref_=otl_0
    https://www.imdb.com/list/ls083599687/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599687/?muuii=Wi
    https://www.imdb.com/list/ls083599687/?mode=desktop
    https://www.imdb.com/list/ls083599201/
    https://www.imdb.com/list/ls083599201/?ref_=otl_C
    https://m.imdb.com/list/ls083599201/
    https://www.imdb.com/list/ls083599201/?ref_=otl_Ak
    https://www.imdb.com/list/ls083599201/?ref_=otl_2
    https://www.imdb.com/list/ls083599201/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599201/?ayoge=Ak
    https://www.imdb.com/list/ls083599201/?mode=desktop
    https://www.imdb.com/list/ls083599250/
    https://www.imdb.com/list/ls083599250/?ref_=otl_4
    https://m.imdb.com/list/ls083599250/
    https://www.imdb.com/list/ls083599250/?ref_=otl_4e
    https://www.imdb.com/list/ls083599250/?ref_=otl_2
    https://www.imdb.com/list/ls083599250/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599250/?ggecg=4e
    https://www.imdb.com/list/ls083599250/?mode=desktop
    https://www.imdb.com/list/ls083599256/
    https://www.imdb.com/list/ls083599256/?ref_=otl_F
    https://m.imdb.com/list/ls083599256/
    https://www.imdb.com/list/ls083599256/?ref_=otl_xT
    https://www.imdb.com/list/ls083599256/?ref_=otl_7
    https://www.imdb.com/list/ls083599256/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599256/?xddln=xT
    https://www.imdb.com/list/ls083599256/?mode=desktop
    https://www.imdb.com/list/ls083599276/
    https://www.imdb.com/list/ls083599276/?ref_=otl_N
    https://m.imdb.com/list/ls083599276/
    https://www.imdb.com/list/ls083599276/?ref_=otl_pP
    https://www.imdb.com/list/ls083599276/?ref_=otl_7
    https://www.imdb.com/list/ls083599276/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599276/?jzbbh=pP
    https://www.imdb.com/list/ls083599276/?mode=desktop
    https://www.imdb.com/list/ls083599278/
    https://www.imdb.com/list/ls083599278/?ref_=otl_g
    https://m.imdb.com/list/ls083599278/
    https://www.imdb.com/list/ls083599278/?ref_=otl_0O
    https://www.imdb.com/list/ls083599278/?ref_=otl_0
    https://www.imdb.com/list/ls083599278/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599278/?oeuai=0O
    https://www.imdb.com/list/ls083599278/?mode=desktop
    https://www.imdb.com/list/ls083599216/
    https://www.imdb.com/list/ls083599216/?ref_=otl_O
    https://m.imdb.com/list/ls083599216/
    https://www.imdb.com/list/ls083599216/?ref_=otl_60
    https://www.imdb.com/list/ls083599216/?ref_=otl_6
    https://www.imdb.com/list/ls083599216/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599216/?ceicm=60
    https://www.imdb.com/list/ls083599216/?mode=desktop
    https://www.imdb.com/list/ls083599218/
    https://www.imdb.com/list/ls083599218/?ref_=otl_6
    https://m.imdb.com/list/ls083599218/
    https://www.imdb.com/list/ls083599218/?ref_=otl_Ao
    https://www.imdb.com/list/ls083599218/?ref_=otl_6
    https://www.imdb.com/list/ls083599218/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599218/?migek=Ao
    https://www.imdb.com/list/ls083599218/?mode=desktop
    https://www.imdb.com/list/ls083599236/
    https://www.imdb.com/list/ls083599236/?ref_=otl_o
    https://m.imdb.com/list/ls083599236/
    https://www.imdb.com/list/ls083599236/?ref_=otl_4Z
    https://www.imdb.com/list/ls083599236/?ref_=otl_5
    https://www.imdb.com/list/ls083599236/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599236/?uyzuz=4Z
    https://www.imdb.com/list/ls083599236/?mode=desktop
    https://www.imdb.com/list/ls083599238/
    https://www.imdb.com/list/ls083599238/?ref_=otl_h
    https://m.imdb.com/list/ls083599238/
    https://www.imdb.com/list/ls083599238/?ref_=otl_Td
    https://www.imdb.com/list/ls083599238/?ref_=otl_9
    https://www.imdb.com/list/ls083599238/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599238/?dtfrv=Td
    https://www.imdb.com/list/ls083599238/?mode=desktop
    https://www.imdb.com/list/ls083599262/
    https://www.imdb.com/list/ls083599262/?ref_=otl_l
    https://m.imdb.com/list/ls083599262/
    https://www.imdb.com/list/ls083599262/?ref_=otl_sO
    https://www.imdb.com/list/ls083599262/?ref_=otl_8
    https://www.imdb.com/list/ls083599262/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599262/?ddwzl=sO
    https://www.imdb.com/list/ls083599262/?mode=desktop
    https://www.imdb.com/list/ls083599227/
    https://www.imdb.com/list/ls083599227/?ref_=otl_q
    https://m.imdb.com/list/ls083599227/
    https://www.imdb.com/list/ls083599227/?ref_=otl_mU
    https://www.imdb.com/list/ls083599227/?ref_=otl_3
    https://www.imdb.com/list/ls083599227/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599227/?fquqb=mU
    https://www.imdb.com/list/ls083599227/?mode=desktop
    https://www.imdb.com/list/ls083599241/
    https://www.imdb.com/list/ls083599241/?ref_=otl_2
    https://m.imdb.com/list/ls083599241/
    https://www.imdb.com/list/ls083599241/?ref_=otl_W4
    https://www.imdb.com/list/ls083599241/?ref_=otl_2
    https://www.imdb.com/list/ls083599241/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599241/?sisqm=W4
    https://www.imdb.com/list/ls083599241/?mode=desktop
    https://www.imdb.com/list/ls083599249/
    https://www.imdb.com/list/ls083599249/?ref_=otl_T
    https://m.imdb.com/list/ls083599249/
    https://www.imdb.com/list/ls083599249/?ref_=otl_1n
    https://www.imdb.com/list/ls083599249/?ref_=otl_3
    https://www.imdb.com/list/ls083599249/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599249/?vfvhj=1n
    https://www.imdb.com/list/ls083599249/?mode=desktop
    https://www.imdb.com/list/ls083599294/
    https://www.imdb.com/list/ls083599294/?ref_=otl_7
    https://m.imdb.com/list/ls083599294/
    https://www.imdb.com/list/ls083599294/?ref_=otl_3L
    https://www.imdb.com/list/ls083599294/?ref_=otl_5
    https://www.imdb.com/list/ls083599294/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599294/?zjhhz=3L
    https://www.imdb.com/list/ls083599294/?mode=desktop
    https://www.imdb.com/list/ls083599282/
    https://www.imdb.com/list/ls083599282/?ref_=otl_N
    https://m.imdb.com/list/ls083599282/
    https://www.imdb.com/list/ls083599282/?ref_=otl_7i
    https://www.imdb.com/list/ls083599282/?ref_=otl_5
    https://www.imdb.com/list/ls083599282/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599282/?innny=7i
    https://www.imdb.com/list/ls083599282/?mode=desktop
    https://www.imdb.com/list/ls083599405/
    https://www.imdb.com/list/ls083599405/?ref_=otl_l
    https://m.imdb.com/list/ls083599405/
    https://www.imdb.com/list/ls083599405/?ref_=otl_HX
    https://www.imdb.com/list/ls083599405/?ref_=otl_1
    https://www.imdb.com/list/ls083599405/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599405/?zjpfr=HX
    https://www.imdb.com/list/ls083599405/?mode=desktop
    https://www.imdb.com/list/ls083599401/
    https://www.imdb.com/list/ls083599401/?ref_=otl_L
    https://m.imdb.com/list/ls083599401/
    https://www.imdb.com/list/ls083599401/?ref_=otl_9j
    https://www.imdb.com/list/ls083599401/?ref_=otl_9
    https://www.imdb.com/list/ls083599401/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599401/?jjjln=9j
    https://www.imdb.com/list/ls083599401/?mode=desktop
    https://www.imdb.com/list/ls083599452/
    https://www.imdb.com/list/ls083599452/?ref_=otl_g
    https://m.imdb.com/list/ls083599452/
    https://www.imdb.com/list/ls083599452/?ref_=otl_Ei
    https://www.imdb.com/list/ls083599452/?ref_=otl_8
    https://www.imdb.com/list/ls083599452/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599452/?iiige=Ei
    https://www.imdb.com/list/ls083599452/?mode=desktop
    https://www.imdb.com/list/ls083599470/
    https://www.imdb.com/list/ls083599470/?ref_=otl_0
    https://m.imdb.com/list/ls083599470/
    https://www.imdb.com/list/ls083599470/?ref_=otl_We
    https://www.imdb.com/list/ls083599470/?ref_=otl_4
    https://www.imdb.com/list/ls083599470/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599470/?wwiga=We
    https://www.imdb.com/list/ls083599470/?mode=desktop
    https://www.imdb.com/list/ls083599474/
    https://www.imdb.com/list/ls083599474/?ref_=otl_4
    https://m.imdb.com/list/ls083599474/
    https://www.imdb.com/list/ls083599474/?ref_=otl_O5
    https://www.imdb.com/list/ls083599474/?ref_=otl_8
    https://www.imdb.com/list/ls083599474/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599474/?pfkng=O5
    https://www.imdb.com/list/ls083599474/?mode=desktop
    https://www.imdb.com/list/ls083599413/
    https://www.imdb.com/list/ls083599413/?ref_=otl_x
    https://m.imdb.com/list/ls083599413/
    https://www.imdb.com/list/ls083599413/?ref_=otl_1n
    https://www.imdb.com/list/ls083599413/?ref_=otl_1
    https://www.imdb.com/list/ls083599413/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599413/?lhjxt=1n
    https://www.imdb.com/list/ls083599413/?mode=desktop
    https://www.imdb.com/list/ls083599418/
    https://www.imdb.com/list/ls083599418/?ref_=otl_G
    https://m.imdb.com/list/ls083599418/
    https://www.imdb.com/list/ls083599418/?ref_=otl_e0
    https://www.imdb.com/list/ls083599418/?ref_=otl_6
    https://www.imdb.com/list/ls083599418/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599418/?cecge=e0
    https://www.imdb.com/list/ls083599418/?mode=desktop
    https://www.imdb.com/list/ls083599436/
    https://www.imdb.com/list/ls083599436/?ref_=otl_P
    https://m.imdb.com/list/ls083599436/
    https://www.imdb.com/list/ls083599436/?ref_=otl_k4
    https://www.imdb.com/list/ls083599436/?ref_=otl_1
    https://www.imdb.com/list/ls083599436/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599436/?pzuek=k4
    https://www.imdb.com/list/ls083599436/?mode=desktop
    https://www.imdb.com/list/ls083599460/
    https://www.imdb.com/list/ls083599460/?ref_=otl_w
    https://m.imdb.com/list/ls083599460/
    https://www.imdb.com/list/ls083599460/?ref_=otl_I4
    https://www.imdb.com/list/ls083599460/?ref_=otl_8
    https://www.imdb.com/list/ls083599460/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599460/?gwwmi=I4
    https://www.imdb.com/list/ls083599460/?mode=desktop
    https://www.imdb.com/list/ls083599469/
    https://www.imdb.com/list/ls083599469/?ref_=otl_m
    https://m.imdb.com/list/ls083599469/
    https://www.imdb.com/list/ls083599469/?ref_=otl_MA
    https://www.imdb.com/list/ls083599469/?ref_=otl_2
    https://www.imdb.com/list/ls083599469/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599469/?mykko=MA
    https://www.imdb.com/list/ls083599469/?mode=desktop
    https://www.imdb.com/list/ls083599427/
    https://www.imdb.com/list/ls083599427/?ref_=otl_J
    https://m.imdb.com/list/ls083599427/
    https://www.imdb.com/list/ls083599427/?ref_=otl_5j
    https://www.imdb.com/list/ls083599427/?ref_=otl_9
    https://www.imdb.com/list/ls083599427/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599427/?llhjl=5j
    https://www.imdb.com/list/ls083599427/?mode=desktop
    https://www.imdb.com/list/ls083599422/
    https://www.imdb.com/list/ls083599422/?ref_=otl_0
    https://m.imdb.com/list/ls083599422/
    https://www.imdb.com/list/ls083599422/?ref_=otl_wm
    https://www.imdb.com/list/ls083599422/?ref_=otl_6
    https://www.imdb.com/list/ls083599422/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599422/?eaaqy=wm
    https://www.imdb.com/list/ls083599422/?mode=desktop
    https://www.imdb.com/list/ls083599441/
    https://www.imdb.com/list/ls083599441/?ref_=otl_b
    https://m.imdb.com/list/ls083599441/
    https://www.imdb.com/list/ls083599441/?ref_=otl_Ej
    https://www.imdb.com/list/ls083599441/?ref_=otl_7
    https://www.imdb.com/list/ls083599441/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599441/?miuxi=Ej
    https://www.imdb.com/list/ls083599441/?mode=desktop
    https://www.imdb.com/list/ls083599492/
    https://www.imdb.com/list/ls083599492/?ref_=otl_r
    https://m.imdb.com/list/ls083599492/
    https://www.imdb.com/list/ls083599492/?ref_=otl_bH
    https://www.imdb.com/list/ls083599492/?ref_=otl_3
    https://www.imdb.com/list/ls083599492/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599492/?jhffr=bH
    https://www.imdb.com/list/ls083599492/?mode=desktop
    https://www.imdb.com/list/ls083599481/
    https://www.imdb.com/list/ls083599481/?ref_=otl_G
    https://m.imdb.com/list/ls083599481/
    https://www.imdb.com/list/ls083599481/?ref_=otl_86
    https://www.imdb.com/list/ls083599481/?ref_=otl_2
    https://www.imdb.com/list/ls083599481/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599481/?iwqqs=86
    https://www.imdb.com/list/ls083599481/?mode=desktop
    https://www.imdb.com/list/ls083599488/
    https://www.imdb.com/list/ls083599488/?ref_=otl_V
    https://m.imdb.com/list/ls083599488/
    https://www.imdb.com/list/ls083599488/?ref_=otl_33
    https://www.imdb.com/list/ls083599488/?ref_=otl_1
    https://www.imdb.com/list/ls083599488/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599488/?drrhh=33
    https://www.imdb.com/list/ls083599488/?mode=desktop
    https://www.imdb.com/list/ls083599951/
    https://www.imdb.com/list/ls083599951/?ref_=otl_7
    https://m.imdb.com/list/ls083599951/
    https://www.imdb.com/list/ls083599951/?ref_=otl_bh
    https://www.imdb.com/list/ls083599951/?ref_=otl_9
    https://www.imdb.com/list/ls083599951/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599951/?tfhnz=bh
    https://www.imdb.com/list/ls083599951/?mode=desktop
    https://www.imdb.com/list/ls083599958/
    https://www.imdb.com/list/ls083599958/?ref_=otl_2
    https://m.imdb.com/list/ls083599958/
    https://www.imdb.com/list/ls083599958/?ref_=otl_88
    https://www.imdb.com/list/ls083599958/?ref_=otl_2
    https://www.imdb.com/list/ls083599958/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599958/?eieoq=88
    https://www.imdb.com/list/ls083599958/?mode=desktop
    https://www.imdb.com/list/ls083599973/
    https://www.imdb.com/list/ls083599973/?ref_=otl_S
    https://m.imdb.com/list/ls083599973/
    https://www.imdb.com/list/ls083599973/?ref_=otl_aQ
    https://www.imdb.com/list/ls083599973/?ref_=otl_6
    https://www.imdb.com/list/ls083599973/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599973/?yqgys=aQ
    https://www.imdb.com/list/ls083599973/?mode=desktop
    https://www.imdb.com/list/ls083599979/
    https://www.imdb.com/list/ls083599979/?ref_=otl_c
    https://m.imdb.com/list/ls083599979/
    https://www.imdb.com/list/ls083599979/?ref_=otl_60
    https://www.imdb.com/list/ls083599979/?ref_=otl_0
    https://www.imdb.com/list/ls083599979/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599979/?mauey=60
    https://www.imdb.com/list/ls083599979/?mode=desktop
    https://www.imdb.com/list/ls083599918/
    https://www.imdb.com/list/ls083599918/?ref_=otl_b
    https://m.imdb.com/list/ls083599918/
    https://www.imdb.com/list/ls083599918/?ref_=otl_p3
    https://www.imdb.com/list/ls083599918/?ref_=otl_1
    https://www.imdb.com/list/ls083599918/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599918/?dpxvh=p3
    https://www.imdb.com/list/ls083599918/?mode=desktop
    https://www.imdb.com/list/ls083599936/
    https://www.imdb.com/list/ls083599936/?ref_=otl_a
    https://m.imdb.com/list/ls083599936/
    https://www.imdb.com/list/ls083599936/?ref_=otl_8Q
    https://www.imdb.com/list/ls083599936/?ref_=otl_6
    https://www.imdb.com/list/ls083599936/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599936/?wwaue=8Q
    https://www.imdb.com/list/ls083599936/?mode=desktop
    https://www.imdb.com/list/ls083599938/
    https://www.imdb.com/list/ls083599938/?ref_=otl_1
    https://m.imdb.com/list/ls083599938/
    https://www.imdb.com/list/ls083599938/?ref_=otl_Nf
    https://www.imdb.com/list/ls083599938/?ref_=otl_7
    https://www.imdb.com/list/ls083599938/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599938/?tdrxd=Nf
    https://www.imdb.com/list/ls083599938/?mode=desktop
    https://www.imdb.com/list/ls083599962/
    https://www.imdb.com/list/ls083599962/?ref_=otl_4
    https://m.imdb.com/list/ls083599962/
    https://www.imdb.com/list/ls083599962/?ref_=otl_6k
    https://www.imdb.com/list/ls083599962/?ref_=otl_2
    https://www.imdb.com/list/ls083599962/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599962/?sukcs=6k
    https://www.imdb.com/list/ls083599962/?mode=desktop
    https://www.imdb.com/list/ls083599927/
    https://www.imdb.com/list/ls083599927/?ref_=otl_8
    https://m.imdb.com/list/ls083599927/
    https://www.imdb.com/list/ls083599927/?ref_=otl_wy
    https://www.imdb.com/list/ls083599927/?ref_=otl_0
    https://www.imdb.com/list/ls083599927/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599927/?wawww=wy
    https://www.imdb.com/list/ls083599927/?mode=desktop
    https://www.imdb.com/list/ls083599940/
    https://www.imdb.com/list/ls083599940/?ref_=otl_9
    https://m.imdb.com/list/ls083599940/
    https://www.imdb.com/list/ls083599940/?ref_=otl_z0
    https://www.imdb.com/list/ls083599940/?ref_=otl_7
    https://www.imdb.com/list/ls083599940/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599940/?pafau=z0
    https://www.imdb.com/list/ls083599940/?mode=desktop
    https://www.imdb.com/list/ls083599948/
    https://www.imdb.com/list/ls083599948/?ref_=otl_b
    https://m.imdb.com/list/ls083599948/
    https://www.imdb.com/list/ls083599948/?ref_=otl_5z
    https://www.imdb.com/list/ls083599948/?ref_=otl_3
    https://www.imdb.com/list/ls083599948/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599948/?nzxfv=5z
    https://www.imdb.com/list/ls083599948/?mode=desktop
    https://www.imdb.com/list/ls083599994/
    https://www.imdb.com/list/ls083599994/?ref_=otl_W
    https://m.imdb.com/list/ls083599994/
    https://www.imdb.com/list/ls083599994/?ref_=otl_44
    https://www.imdb.com/list/ls083599994/?ref_=otl_8
    https://www.imdb.com/list/ls083599994/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599994/?migqq=44
    https://www.imdb.com/list/ls083599994/?mode=desktop
    https://www.imdb.com/list/ls083599986/
    https://www.imdb.com/list/ls083599986/?ref_=otl_n
    https://m.imdb.com/list/ls083599986/
    https://www.imdb.com/list/ls083599986/?ref_=otl_3P
    https://www.imdb.com/list/ls083599986/?ref_=otl_5
    https://www.imdb.com/list/ls083599986/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599986/?ppprp=3P
    https://www.imdb.com/list/ls083599986/?mode=desktop
    https://www.imdb.com/list/ls083599807/
    https://www.imdb.com/list/ls083599807/?ref_=otl_5
    https://m.imdb.com/list/ls083599807/
    https://www.imdb.com/list/ls083599807/?ref_=otl_H9
    https://www.imdb.com/list/ls083599807/?ref_=otl_5
    https://www.imdb.com/list/ls083599807/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599807/?fjbtd=H9
    https://www.imdb.com/list/ls083599807/?mode=desktop
    https://www.imdb.com/list/ls083599856/
    https://www.imdb.com/list/ls083599856/?ref_=otl_W
    https://m.imdb.com/list/ls083599856/
    https://www.imdb.com/list/ls083599856/?ref_=otl_K8
    https://www.imdb.com/list/ls083599856/?ref_=otl_4
    https://www.imdb.com/list/ls083599856/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599856/?mqmgm=K8
    https://www.imdb.com/list/ls083599856/?mode=desktop
    https://www.imdb.com/list/ls083599876/
    https://www.imdb.com/list/ls083599876/?ref_=otl_P
    https://m.imdb.com/list/ls083599876/
    https://www.imdb.com/list/ls083599876/?ref_=otl_Hx
    https://www.imdb.com/list/ls083599876/?ref_=otl_5
    https://www.imdb.com/list/ls083599876/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599876/?hhdbz=Hx
    https://www.imdb.com/list/ls083599876/?mode=desktop
    https://www.imdb.com/list/ls083599813/
    https://www.imdb.com/list/ls083599813/?ref_=otl_f
    https://m.imdb.com/list/ls083599813/
    https://www.imdb.com/list/ls083599813/?ref_=otl_5N
    https://www.imdb.com/list/ls083599813/?ref_=otl_3
    https://www.imdb.com/list/ls083599813/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599813/?nbdtn=5N
    https://www.imdb.com/list/ls083599813/?mode=desktop
    https://www.imdb.com/list/ls083599830/
    https://www.imdb.com/list/ls083599830/?ref_=otl_o
    https://m.imdb.com/list/ls083599830/
    https://www.imdb.com/list/ls083599830/?ref_=otl_kw
    https://www.imdb.com/list/ls083599830/?ref_=otl_2
    https://www.imdb.com/list/ls083599830/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599830/?ocyea=kw
    https://www.imdb.com/list/ls083599830/?mode=desktop
    https://www.imdb.com/list/ls083599860/
    https://www.imdb.com/list/ls083599860/?ref_=otl_Q
    https://m.imdb.com/list/ls083599860/
    https://www.imdb.com/list/ls083599860/?ref_=otl_k0
    https://www.imdb.com/list/ls083599860/?ref_=otl_2
    https://www.imdb.com/list/ls083599860/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599860/?uqmsg=k0
    https://www.imdb.com/list/ls083599860/?mode=desktop
    https://www.imdb.com/list/ls083599869/
    https://www.imdb.com/list/ls083599869/?ref_=otl_2
    https://m.imdb.com/list/ls083599869/
    https://www.imdb.com/list/ls083599869/?ref_=otl_u0
    https://www.imdb.com/list/ls083599869/?ref_=otl_6
    https://www.imdb.com/list/ls083599869/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599869/?usqqs=u0
    https://www.imdb.com/list/ls083599869/?mode=desktop
    https://www.imdb.com/list/ls083599822/
    https://www.imdb.com/list/ls083599822/?ref_=otl_b
    https://m.imdb.com/list/ls083599822/
    https://www.imdb.com/list/ls083599822/?ref_=otl_lh
    https://www.imdb.com/list/ls083599822/?ref_=otl_7
    https://www.imdb.com/list/ls083599822/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599822/?zxdzn=lh
    https://www.imdb.com/list/ls083599822/?mode=desktop
    https://www.imdb.com/list/ls083599845/
    https://www.imdb.com/list/ls083599845/?ref_=otl_8
    https://m.imdb.com/list/ls083599845/
    https://www.imdb.com/list/ls083599845/?ref_=otl_AU
    https://www.imdb.com/list/ls083599845/?ref_=otl_6
    https://www.imdb.com/list/ls083599845/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599845/?oqyeg=AU
    https://www.imdb.com/list/ls083599845/?mode=desktop
    https://www.imdb.com/list/ls083599891/
    https://www.imdb.com/list/ls083599891/?ref_=otl_u
    https://m.imdb.com/list/ls083599891/
    https://www.imdb.com/list/ls083599891/?ref_=otl_a0
    https://www.imdb.com/list/ls083599891/?ref_=otl_2
    https://www.imdb.com/list/ls083599891/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599891/?awckm=a0
    https://www.imdb.com/list/ls083599891/?mode=desktop
    https://www.imdb.com/list/ls083599899/
    https://www.imdb.com/list/ls083599899/?ref_=otl_y
    https://m.imdb.com/list/ls083599899/
    https://www.imdb.com/list/ls083599899/?ref_=otl_D1
    https://www.imdb.com/list/ls083599899/?ref_=otl_1
    https://www.imdb.com/list/ls083599899/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599899/?totey=D1
    https://www.imdb.com/list/ls083599899/?mode=desktop
    https://www.imdb.com/list/ls083599889/
    https://www.imdb.com/list/ls083599889/?ref_=otl_r
    https://m.imdb.com/list/ls083599889/
    https://www.imdb.com/list/ls083599889/?ref_=otl_rt
    https://www.imdb.com/list/ls083599889/?ref_=otl_7
    https://www.imdb.com/list/ls083599889/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083599889/?ttprt=rt
    https://www.imdb.com/list/ls083599889/?mode=desktop
    https://www.imdb.com/list/ls083598007/
    https://www.imdb.com/list/ls083598007/?ref_=otl_6
    https://m.imdb.com/list/ls083598007/
    https://www.imdb.com/list/ls083598007/?ref_=otl_4I
    https://www.imdb.com/list/ls083598007/?ref_=otl_6
    https://www.imdb.com/list/ls083598007/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598007/?wakyu=4I
    https://www.imdb.com/list/ls083598007/?mode=desktop
    https://www.imdb.com/list/ls083598008/
    https://www.imdb.com/list/ls083598008/?ref_=otl_9
    https://m.imdb.com/list/ls083598008/
    https://www.imdb.com/list/ls083598008/?ref_=otl_1j
    https://www.imdb.com/list/ls083598008/?ref_=otl_7
    https://www.imdb.com/list/ls083598008/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598008/?nlbrp=1j
    https://www.imdb.com/list/ls083598008/?mode=desktop
    https://www.imdb.com/list/ls083598057/
    https://www.imdb.com/list/ls083598057/?ref_=otl_7
    https://m.imdb.com/list/ls083598057/
    https://www.imdb.com/list/ls083598057/?ref_=otl_hH
    https://www.imdb.com/list/ls083598057/?ref_=otl_3
    https://www.imdb.com/list/ls083598057/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598057/?hdffh=hH
    https://www.imdb.com/list/ls083598057/?mode=desktop
    https://www.imdb.com/list/ls083598058/
    https://www.imdb.com/list/ls083598058/?ref_=otl_n
    https://m.imdb.com/list/ls083598058/
    https://www.imdb.com/list/ls083598058/?ref_=otl_l7
    https://www.imdb.com/list/ls083598058/?ref_=otl_1
    https://www.imdb.com/list/ls083598058/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598058/?llljn=l7
    https://www.imdb.com/list/ls083598058/?mode=desktop
    https://www.imdb.com/list/ls083598073/
    https://www.imdb.com/list/ls083598073/?ref_=otl_N
    https://m.imdb.com/list/ls083598073/
    https://www.imdb.com/list/ls083598073/?ref_=otl_9N
    https://www.imdb.com/list/ls083598073/?ref_=otl_7
    https://www.imdb.com/list/ls083598073/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598073/?vbnjv=9N
    https://www.imdb.com/list/ls083598073/?mode=desktop
    https://www.imdb.com/list/ls083598079/
    https://www.imdb.com/list/ls083598079/?ref_=otl_a
    https://m.imdb.com/list/ls083598079/
    https://www.imdb.com/list/ls083598079/?ref_=otl_WI
    https://www.imdb.com/list/ls083598079/?ref_=otl_4
    https://www.imdb.com/list/ls083598079/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598079/?iyuyc=WI
    https://www.imdb.com/list/ls083598079/?mode=desktop
    https://www.imdb.com/list/ls083598018/
    https://www.imdb.com/list/ls083598018/?ref_=otl_l
    https://m.imdb.com/list/ls083598018/
    https://www.imdb.com/list/ls083598018/?ref_=otl_p1
    https://www.imdb.com/list/ls083598018/?ref_=otl_9
    https://www.imdb.com/list/ls083598018/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598018/?dtfxx=p1
    https://www.imdb.com/list/ls083598018/?mode=desktop
    https://www.imdb.com/list/ls083598033/
    https://www.imdb.com/list/ls083598033/?ref_=otl_h
    https://m.imdb.com/list/ls083598033/
    https://www.imdb.com/list/ls083598033/?ref_=otl_P3
    https://www.imdb.com/list/ls083598033/?ref_=otl_3
    https://www.imdb.com/list/ls083598033/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598033/?rphvh=P3
    https://www.imdb.com/list/ls083598033/?mode=desktop
    https://www.imdb.com/list/ls083598038/
    https://www.imdb.com/list/ls083598038/?ref_=otl_7
    https://m.imdb.com/list/ls083598038/
    https://www.imdb.com/list/ls083598038/?ref_=otl_X1
    https://www.imdb.com/list/ls083598038/?ref_=otl_7
    https://www.imdb.com/list/ls083598038/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598038/?vzfak=X1
    https://www.imdb.com/list/ls083598038/?mode=desktop
    https://www.imdb.com/list/ls083598063/
    https://www.imdb.com/list/ls083598063/?ref_=otl_L
    https://m.imdb.com/list/ls083598063/
    https://www.imdb.com/list/ls083598063/?ref_=otl_LZ
    https://www.imdb.com/list/ls083598063/?ref_=otl_9
    https://www.imdb.com/list/ls083598063/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598063/?xtvtx=LZ
    https://www.imdb.com/list/ls083598063/?mode=desktop
    https://www.imdb.com/list/ls083598020/
    https://www.imdb.com/list/ls083598020/?ref_=otl_I
    https://m.imdb.com/list/ls083598020/
    https://www.imdb.com/list/ls083598020/?ref_=otl_4I
    https://www.imdb.com/list/ls083598020/?ref_=otl_4
    https://www.imdb.com/list/ls083598020/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598020/?qmwwi=4I
    https://www.imdb.com/list/ls083598020/?mode=desktop
    https://www.imdb.com/list/ls083598026/
    https://www.imdb.com/list/ls083598026/?ref_=otl_5
    https://m.imdb.com/list/ls083598026/
    https://www.imdb.com/list/ls083598026/?ref_=otl_P7
    https://www.imdb.com/list/ls083598026/?ref_=otl_1
    https://www.imdb.com/list/ls083598026/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598026/?rbdnz=P7
    https://www.imdb.com/list/ls083598026/?mode=desktop
    https://www.imdb.com/list/ls083598045/
    https://www.imdb.com/list/ls083598045/?ref_=otl_v
    https://m.imdb.com/list/ls083598045/
    https://www.imdb.com/list/ls083598045/?ref_=otl_n7
    https://www.imdb.com/list/ls083598045/?ref_=otl_9
    https://www.imdb.com/list/ls083598045/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598045/?vnbbn=n7
    https://www.imdb.com/list/ls083598045/?mode=desktop
    https://www.imdb.com/list/ls083598091/
    https://www.imdb.com/list/ls083598091/?ref_=otl_l
    https://m.imdb.com/list/ls083598091/
    https://www.imdb.com/list/ls083598091/?ref_=otl_N9
    https://www.imdb.com/list/ls083598091/?ref_=otl_1
    https://www.imdb.com/list/ls083598091/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598091/?vlhrb=N9
    https://www.imdb.com/list/ls083598091/?mode=desktop
    https://www.imdb.com/list/ls083598087/
    https://www.imdb.com/list/ls083598087/?ref_=otl_6
    https://m.imdb.com/list/ls083598087/
    https://www.imdb.com/list/ls083598087/?ref_=otl_a6
    https://www.imdb.com/list/ls083598087/?ref_=otl_4
    https://www.imdb.com/list/ls083598087/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598087/?ycaaa=a6
    https://www.imdb.com/list/ls083598087/?mode=desktop
    https://www.imdb.com/list/ls083598084/
    https://www.imdb.com/list/ls083598084/?ref_=otl_2
    https://m.imdb.com/list/ls083598084/
    https://www.imdb.com/list/ls083598084/?ref_=otl_i0
    https://www.imdb.com/list/ls083598084/?ref_=otl_2
    https://www.imdb.com/list/ls083598084/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598084/?emkms=i0
    https://www.imdb.com/list/ls083598084/?mode=desktop
    https://www.imdb.com/list/ls083598503/
    https://www.imdb.com/list/ls083598503/?ref_=otl_F
    https://m.imdb.com/list/ls083598503/
    https://www.imdb.com/list/ls083598503/?ref_=otl_Fd
    https://www.imdb.com/list/ls083598503/?ref_=otl_5
    https://www.imdb.com/list/ls083598503/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598503/?ddhdd=Fd
    https://www.imdb.com/list/ls083598503/?mode=desktop
    https://www.imdb.com/list/ls083598559/
    https://www.imdb.com/list/ls083598559/?ref_=otl_W
    https://m.imdb.com/list/ls083598559/
    https://www.imdb.com/list/ls083598559/?ref_=otl_8i
    https://www.imdb.com/list/ls083598559/?ref_=otl_0
    https://www.imdb.com/list/ls083598559/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598559/?cqusy=8i
    https://www.imdb.com/list/ls083598559/?mode=desktop
    https://www.imdb.com/list/ls083598576/
    https://www.imdb.com/list/ls083598576/?ref_=otl_n
    https://m.imdb.com/list/ls083598576/
    https://www.imdb.com/list/ls083598576/?ref_=otl_pr
    https://www.imdb.com/list/ls083598576/?ref_=otl_3
    https://www.imdb.com/list/ls083598576/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598576/?rnppp=pr
    https://www.imdb.com/list/ls083598576/?mode=desktop
    https://www.imdb.com/list/ls083598511/
    https://www.imdb.com/list/ls083598511/?ref_=otl_e
    https://m.imdb.com/list/ls083598511/
    https://www.imdb.com/list/ls083598511/?ref_=otl_80
    https://www.imdb.com/list/ls083598511/?ref_=otl_2
    https://www.imdb.com/list/ls083598511/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598511/?gwaqm=80
    https://www.imdb.com/list/ls083598511/?mode=desktop
    https://www.imdb.com/list/ls083598531/
    https://www.imdb.com/list/ls083598531/?ref_=otl_V
    https://m.imdb.com/list/ls083598531/
    https://www.imdb.com/list/ls083598531/?ref_=otl_5l
    https://www.imdb.com/list/ls083598531/?ref_=otl_9
    https://www.imdb.com/list/ls083598531/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598531/?fjfxx=5l
    https://www.imdb.com/list/ls083598531/?mode=desktop
    https://www.imdb.com/list/ls083598534/
    https://www.imdb.com/list/ls083598534/?ref_=otl_a
    https://m.imdb.com/list/ls083598534/
    https://www.imdb.com/list/ls083598534/?ref_=otl_6a
    https://www.imdb.com/list/ls083598534/?ref_=otl_8
    https://www.imdb.com/list/ls083598534/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598534/?cacae=6a
    https://www.imdb.com/list/ls083598534/?mode=desktop
    https://www.imdb.com/list/ls083598562/
    https://www.imdb.com/list/ls083598562/?ref_=otl_D
    https://m.imdb.com/list/ls083598562/
    https://www.imdb.com/list/ls083598562/?ref_=otl_7v
    https://www.imdb.com/list/ls083598562/?ref_=otl_1
    https://www.imdb.com/list/ls083598562/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598562/?pbzvp=7v
    https://www.imdb.com/list/ls083598562/?mode=desktop
    https://www.imdb.com/list/ls083598523/
    https://www.imdb.com/list/ls083598523/?ref_=otl_1
    https://m.imdb.com/list/ls083598523/
    https://www.imdb.com/list/ls083598523/?ref_=otl_Rn
    https://www.imdb.com/list/ls083598523/?ref_=otl_5
    https://www.imdb.com/list/ls083598523/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598523/?tvhtn=Rn
    https://www.imdb.com/list/ls083598523/?mode=desktop
    https://www.imdb.com/list/ls083598540/
    https://www.imdb.com/list/ls083598540/?ref_=otl_A
    https://m.imdb.com/list/ls083598540/
    https://www.imdb.com/list/ls083598540/?ref_=otl_Ky
    https://www.imdb.com/list/ls083598540/?ref_=otl_0
    https://www.imdb.com/list/ls083598540/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598540/?cyuig=Ky
    https://www.imdb.com/list/ls083598540/?mode=desktop
    https://www.imdb.com/list/ls083598543/
    https://www.imdb.com/list/ls083598543/?ref_=otl_q
    https://m.imdb.com/list/ls083598543/
    https://www.imdb.com/list/ls083598543/?ref_=otl_Ko
    https://www.imdb.com/list/ls083598543/?ref_=otl_0
    https://www.imdb.com/list/ls083598543/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598543/?yeusc=Ko
    https://www.imdb.com/list/ls083598543/?mode=desktop
    https://www.imdb.com/list/ls083598591/
    https://www.imdb.com/list/ls083598591/?ref_=otl_B
    https://m.imdb.com/list/ls083598591/
    https://www.imdb.com/list/ls083598591/?ref_=otl_P3
    https://www.imdb.com/list/ls083598591/?ref_=otl_9
    https://www.imdb.com/list/ls083598591/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598591/?xdnnb=P3
    https://www.imdb.com/list/ls083598591/?mode=desktop
    https://www.imdb.com/list/ls083598585/
    https://www.imdb.com/list/ls083598585/?ref_=otl_1
    https://m.imdb.com/list/ls083598585/
    https://www.imdb.com/list/ls083598585/?ref_=otl_19
    https://www.imdb.com/list/ls083598585/?ref_=otl_3
    https://www.imdb.com/list/ls083598585/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598585/?vrzft=19
    https://www.imdb.com/list/ls083598585/?mode=desktop
    https://www.imdb.com/list/ls083598589/
    https://www.imdb.com/list/ls083598589/?ref_=otl_6
    https://m.imdb.com/list/ls083598589/
    https://www.imdb.com/list/ls083598589/?ref_=otl_6C
    https://www.imdb.com/list/ls083598589/?ref_=otl_4
    https://www.imdb.com/list/ls083598589/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598589/?suuqi=6C
    https://www.imdb.com/list/ls083598589/?mode=desktop
    https://www.imdb.com/list/ls083598704/
    https://www.imdb.com/list/ls083598704/?ref_=otl_6
    https://m.imdb.com/list/ls083598704/
    https://www.imdb.com/list/ls083598704/?ref_=otl_42
    https://www.imdb.com/list/ls083598704/?ref_=otl_6
    https://www.imdb.com/list/ls083598704/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598704/?weeck=42
    https://www.imdb.com/list/ls083598704/?mode=desktop
    https://www.imdb.com/list/ls083598754/
    https://www.imdb.com/list/ls083598754/?ref_=otl_o
    https://m.imdb.com/list/ls083598754/
    https://www.imdb.com/list/ls083598754/?ref_=otl_2Q
    https://www.imdb.com/list/ls083598754/?ref_=otl_8
    https://www.imdb.com/list/ls083598754/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598754/?sqiec=2Q
    https://www.imdb.com/list/ls083598754/?mode=desktop
    https://www.imdb.com/list/ls083598776/
    https://www.imdb.com/list/ls083598776/?ref_=otl_j
    https://m.imdb.com/list/ls083598776/
    https://www.imdb.com/list/ls083598776/?ref_=otl_Rn
    https://www.imdb.com/list/ls083598776/?ref_=otl_5
    https://www.imdb.com/list/ls083598776/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598776/?vlrbb=Rn
    https://www.imdb.com/list/ls083598776/?mode=desktop
    https://www.imdb.com/list/ls083598778/
    https://www.imdb.com/list/ls083598778/?ref_=otl_d
    https://m.imdb.com/list/ls083598778/
    https://www.imdb.com/list/ls083598778/?ref_=otl_3J
    https://www.imdb.com/list/ls083598778/?ref_=otl_1
    https://www.imdb.com/list/ls083598778/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598778/?dnbtx=3J
    https://www.imdb.com/list/ls083598778/?mode=desktop
    https://www.imdb.com/list/ls083598718/
    https://www.imdb.com/list/ls083598718/?ref_=otl_M
    https://m.imdb.com/list/ls083598718/
    https://www.imdb.com/list/ls083598718/?ref_=otl_WC
    https://www.imdb.com/list/ls083598718/?ref_=otl_5
    https://www.imdb.com/list/ls083598718/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598718/?oomsq=WC
    https://www.imdb.com/list/ls083598718/?mode=desktop
    https://www.imdb.com/list/ls083598760/
    https://www.imdb.com/list/ls083598760/?ref_=otl_v
    https://m.imdb.com/list/ls083598760/
    https://www.imdb.com/list/ls083598760/?ref_=otl_F1
    https://www.imdb.com/list/ls083598760/?ref_=otl_5
    https://www.imdb.com/list/ls083598760/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598760/?vvffh=F1
    https://www.imdb.com/list/ls083598760/?mode=desktop
    https://www.imdb.com/list/ls083598762/
    https://www.imdb.com/list/ls083598762/?ref_=otl_T
    https://m.imdb.com/list/ls083598762/
    https://www.imdb.com/list/ls083598762/?ref_=otl_9p
    https://www.imdb.com/list/ls083598762/?ref_=otl_1
    https://www.imdb.com/list/ls083598762/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598762/?jtxvv=9p
    https://www.imdb.com/list/ls083598762/?mode=desktop
    https://www.imdb.com/list/ls083598725/
    https://www.imdb.com/list/ls083598725/?ref_=otl_9
    https://m.imdb.com/list/ls083598725/
    https://www.imdb.com/list/ls083598725/?ref_=otl_th
    https://www.imdb.com/list/ls083598725/?ref_=otl_1
    https://www.imdb.com/list/ls083598725/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598725/?bthfb=th
    https://www.imdb.com/list/ls083598725/?mode=desktop
    https://www.imdb.com/list/ls083598729/
    https://www.imdb.com/list/ls083598729/?ref_=otl_H
    https://m.imdb.com/list/ls083598729/
    https://www.imdb.com/list/ls083598729/?ref_=otl_d5
    https://www.imdb.com/list/ls083598729/?ref_=otl_7
    https://www.imdb.com/list/ls083598729/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598729/?rvfnb=d5
    https://www.imdb.com/list/ls083598729/?mode=desktop
    https://www.imdb.com/list/ls083598743/
    https://www.imdb.com/list/ls083598743/?ref_=otl_3
    https://m.imdb.com/list/ls083598743/
    https://www.imdb.com/list/ls083598743/?ref_=otl_5X
    https://www.imdb.com/list/ls083598743/?ref_=otl_1
    https://www.imdb.com/list/ls083598743/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598743/?zvvvx=5X
    https://www.imdb.com/list/ls083598743/?mode=desktop
    https://www.imdb.com/list/ls083598795/
    https://www.imdb.com/list/ls083598795/?ref_=otl_M
    https://m.imdb.com/list/ls083598795/
    https://www.imdb.com/list/ls083598795/?ref_=otl_2A
    https://www.imdb.com/list/ls083598795/?ref_=otl_8
    https://www.imdb.com/list/ls083598795/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598795/?gwqcs=2A
    https://www.imdb.com/list/ls083598795/?mode=desktop
    https://www.imdb.com/list/ls083598798/
    https://www.imdb.com/list/ls083598798/?ref_=otl_Y
    https://m.imdb.com/list/ls083598798/
    https://www.imdb.com/list/ls083598798/?ref_=otl_CE
    https://www.imdb.com/list/ls083598798/?ref_=otl_6
    https://www.imdb.com/list/ls083598798/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598798/?umsaa=CE
    https://www.imdb.com/list/ls083598798/?mode=desktop
    https://www.imdb.com/list/ls083598787/
    https://www.imdb.com/list/ls083598787/?ref_=otl_5
    https://m.imdb.com/list/ls083598787/
    https://www.imdb.com/list/ls083598787/?ref_=otl_T3
    https://www.imdb.com/list/ls083598787/?ref_=otl_3
    https://www.imdb.com/list/ls083598787/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598787/?btxrj=T3
    https://www.imdb.com/list/ls083598787/?mode=desktop
    https://www.imdb.com/list/ls083598784/
    https://www.imdb.com/list/ls083598784/?ref_=otl_7
    https://m.imdb.com/list/ls083598784/
    https://www.imdb.com/list/ls083598784/?ref_=otl_5R
    https://www.imdb.com/list/ls083598784/?ref_=otl_5
    https://www.imdb.com/list/ls083598784/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598784/?rtvvv=5R
    https://www.imdb.com/list/ls083598784/?mode=desktop
    https://www.imdb.com/list/ls083598103/
    https://www.imdb.com/list/ls083598103/?ref_=otl_2
    https://m.imdb.com/list/ls083598103/
    https://www.imdb.com/list/ls083598103/?ref_=otl_aA
    https://www.imdb.com/list/ls083598103/?ref_=otl_2
    https://www.imdb.com/list/ls083598103/?mode=desktop&ref_=m_ft_dsk
    https://www.imdb.com/list/ls083598103/?qyemy=aA
    https://www.imdb.com/list/ls083598103/?mode=desktop

    展开全文
  • 完整的c++串口编程源代码.rar
  • 最近学弟要用Window下的串口编程,我把串口类封装了一遍,非常容易加入其它工程项目。代码都已可以直接运行,测试代码我也写了,都是可以用的。
  • 自己 一步步 实现的C++MFC串口编程的小实例
  • 在windows程序设计与开发过程中,特别是涉及到开发嵌入式软硬件系统时,往往会涉及到串口编程。网上以及一些书籍上讲解windows下的串口编程知识也挺多的,但我个人觉得,看完书上的知识点有时依然不知道该如何下手...
  • 一个用于VC串口开发的工具类。简单实用。做串口开发的童鞋不用再头疼了,工具类可以直接使用。注意是vc++版本
  • C++串口编程 求助

    2015-07-18 14:45:09
    最近看了几本书,串口助手的源代码也看了,基本能懂,但是为什么自己写就是写不出来,求大家知道一下!感激不尽啊
  • Windows下C++ 串口编程实例

    万次阅读 多人点赞 2016-02-23 15:01:09
    4. 本例子只实现了串口数据的基本收发功能,其实为了保证串口数据传输的正确性,往往需要设计一些串口通信协议,协议的设计有待你自己完成,如果以后有时间,我也会尝试提供一种比较基本的串口通信协议设计案例给...

    原文链接:http://blog.sina.com.cn/s/blog_afb1793101016mq2.html

    1. 本例子使用了比较规范的软件设计方法,类的设计具有比较好的可扩展性和移植性、代码的注释采用doxgen支持的javaDoc风格。
    2. 为了能方便初学者更快地了解和入门,几乎每一行代码都加上了详细的注释,对于注释中如果依然有不清楚的概念,相信你通过百度和google一定能找到答案。
    3. 本例子设计的串口操作类可以直接移植到其他的工程中去,大家也可以根据自己的需要添加其他的接口。
    4. 本例子只实现了串口数据的基本收发功能,其实为了保证串口数据传输的正确性,往往需要设计一些串口通信协议,协议的设计有待你自己完成,如果以后有时间,我也会尝试提供一种比较基本的串口通信协议设计案例给大家学习。
    5. 关于本程序的验证方法,可以使用虚拟串口软件VSPM和串口调试助手进行程序的测试与验证. 

    下面即为例子工程的三个文件,SerialPort.h、SerialPort.cpp、maincpp
     
    工程文件,需要使用vs2008打开。下载

    SerialPort.h

    //  
    /// COPYRIGHT NOTICE  
    /// Copyright (c) 2009, 华中科技大学tickTick Group  (版权声明)  
    /// All rights reserved.  
    ///   
    /// @file    SerialPort.h    
    /// @brief   串口通信类头文件  
    ///  
    /// 本文件完成串口通信类的声明  
    ///  
    /// @version 1.0     
    /// @author  卢俊   
    /// @E-mail:lujun.hust@gmail.com  
    /// @date    2010/03/19  
    ///  
    ///  修订说明:  
    //  
    
    #ifndef SERIALPORT_H_  
    #define SERIALPORT_H_  
    
    #include <Windows.h>  
    
    /** 串口通信类
    *
    *  本类实现了对串口的基本操作
    *  例如监听发到指定串口的数据、发送指定数据到串口
    */
    class CSerialPort
    {
    public:
    	CSerialPort(void);
    	~CSerialPort(void);
    
    public:
    
    	/** 初始化串口函数
    	*
    	*  @param:  UINT portNo 串口编号,默认值为1,即COM1,注意,尽量不要大于9
    	*  @param:  UINT baud   波特率,默认为9600
    	*  @param:  char parity 是否进行奇偶校验,'Y'表示需要奇偶校验,'N'表示不需要奇偶校验
    	*  @param:  UINT databits 数据位的个数,默认值为8个数据位
    	*  @param:  UINT stopsbits 停止位使用格式,默认值为1
    	*  @param:  DWORD dwCommEvents 默认为EV_RXCHAR,即只要收发任意一个字符,则产生一个事件
    	*  @return: bool  初始化是否成功
    	*  @note:   在使用其他本类提供的函数前,请先调用本函数进行串口的初始化
    	*        /n本函数提供了一些常用的串口参数设置,若需要自行设置详细的DCB参数,可使用重载函数
    	*           /n本串口类析构时会自动关闭串口,无需额外执行关闭串口
    	*  @see:
    	*/
    	bool InitPort(UINT  portNo = 1, UINT  baud = CBR_9600, char  parity = 'N', UINT  databits = 8, UINT  stopsbits = 1, DWORD dwCommEvents = EV_RXCHAR);
    
    	/** 串口初始化函数
    	*
    	*  本函数提供直接根据DCB参数设置串口参数
    	*  @param:  UINT portNo
    	*  @param:  const LPDCB & plDCB
    	*  @return: bool  初始化是否成功
    	*  @note:   本函数提供用户自定义地串口初始化参数
    	*  @see:
    	*/
    	bool InitPort(UINT  portNo, const LPDCB& plDCB);
    
    	/** 开启监听线程
    	*
    	*  本监听线程完成对串口数据的监听,并将接收到的数据打印到屏幕输出
    	*  @return: bool  操作是否成功
    	*  @note:   当线程已经处于开启状态时,返回flase
    	*  @see:
    	*/
    	bool OpenListenThread();
    
    	/** 关闭监听线程
    	*
    	*
    	*  @return: bool  操作是否成功
    	*  @note:   调用本函数后,监听串口的线程将会被关闭
    	*  @see:
    	*/
    	bool CloseListenTread();
    
    	/** 向串口写数据
    	*
    	*  将缓冲区中的数据写入到串口
    	*  @param:  unsigned char * pData 指向需要写入串口的数据缓冲区
    	*  @param:  unsigned int length 需要写入的数据长度
    	*  @return: bool  操作是否成功
    	*  @note:   length不要大于pData所指向缓冲区的大小
    	*  @see:
    	*/
    	bool WriteData(unsigned char* pData, unsigned int length);
    
    	/** 获取串口缓冲区中的字节数
    	*
    	*
    	*  @return: UINT  操作是否成功
    	*  @note:   当串口缓冲区中无数据时,返回0
    	*  @see:
    	*/
    	UINT GetBytesInCOM();
    
    	/** 读取串口接收缓冲区中一个字节的数据
    	*
    	*
    	*  @param:  char & cRecved 存放读取数据的字符变量
    	*  @return: bool  读取是否成功
    	*  @note:
    	*  @see:
    	*/
    	bool ReadChar(char &cRecved);
    
    private:
    
    	/** 打开串口
    	*
    	*
    	*  @param:  UINT portNo 串口设备号
    	*  @return: bool  打开是否成功
    	*  @note:
    	*  @see:
    	*/
    	bool openPort(UINT  portNo);
    
    	/** 关闭串口
    	*
    	*
    	*  @return: void  操作是否成功
    	*  @note:
    	*  @see:
    	*/
    	void ClosePort();
    
    	/** 串口监听线程
    	*
    	*  监听来自串口的数据和信息
    	*  @param:  void * pParam 线程参数
    	*  @return: UINT WINAPI 线程返回值
    	*  @note:
    	*  @see:
    	*/
    	static UINT WINAPI ListenThread(void* pParam);
    
    private:
    
    	/** 串口句柄 */
    	HANDLE  m_hComm;
    
    	/** 线程退出标志变量 */
    	static bool s_bExit;
    
    	/** 线程句柄 */
    	volatile HANDLE    m_hListenThread;
    
    	/** 同步互斥,临界区保护 */
    	CRITICAL_SECTION   m_csCommunicationSync;       //!< 互斥操作串口  
    
    };
    
    #endif //SERIALPORT_H_ 


    SerialPort.cpp

    //  
    /// COPYRIGHT NOTICE  
    /// Copyright (c) 2009, 华中科技大学tickTick Group  (版权声明)  
    /// All rights reserved.  
    ///   
    /// @file    SerialPort.cpp    
    /// @brief   串口通信类的实现文件  
    ///  
    /// 本文件为串口通信类的实现代码  
    ///  
    /// @version 1.0     
    /// @author  卢俊    
    /// @E-mail:lujun.hust@gmail.com  
    /// @date    2010/03/19  
    ///   
    ///  
    ///  修订说明:  
    //  
    
    #include "StdAfx.h"  
    #include "SerialPort.h"  
    #include <process.h>  
    #include <iostream>  
    
    /** 线程退出标志 */
    bool CSerialPort::s_bExit = false;
    /** 当串口无数据时,sleep至下次查询间隔的时间,单位:秒 */
    const UINT SLEEP_TIME_INTERVAL = 5;
    
    CSerialPort::CSerialPort(void)
    	: m_hListenThread(INVALID_HANDLE_VALUE)
    {
    	m_hComm = INVALID_HANDLE_VALUE;
    	m_hListenThread = INVALID_HANDLE_VALUE;
    
    	InitializeCriticalSection(&m_csCommunicationSync);
    
    }
    
    CSerialPort::~CSerialPort(void)
    {
    	CloseListenTread();
    	ClosePort();
    	DeleteCriticalSection(&m_csCommunicationSync);
    }
    
    bool CSerialPort::InitPort(UINT portNo /*= 1*/, UINT baud /*= CBR_9600*/, char parity /*= 'N'*/,
    	UINT databits /*= 8*/, UINT stopsbits /*= 1*/, DWORD dwCommEvents /*= EV_RXCHAR*/)
    {
    
    	/** 临时变量,将制定参数转化为字符串形式,以构造DCB结构 */
    	char szDCBparam[50];
    	sprintf_s(szDCBparam, "baud=%d parity=%c data=%d stop=%d", baud, parity, databits, stopsbits);
    
    	/** 打开指定串口,该函数内部已经有临界区保护,上面请不要加保护 */
    	if (!openPort(portNo))
    	{
    		return false;
    	}
    
    	/** 进入临界段 */
    	EnterCriticalSection(&m_csCommunicationSync);
    
    	/** 是否有错误发生 */
    	BOOL bIsSuccess = TRUE;
    
    	/** 在此可以设置输入输出的缓冲区大小,如果不设置,则系统会设置默认值.
    	*  自己设置缓冲区大小时,要注意设置稍大一些,避免缓冲区溢出
    	*/
    	/*if (bIsSuccess )
    	{
    	bIsSuccess = SetupComm(m_hComm,10,10);
    	}*/
    
    	/** 设置串口的超时时间,均设为0,表示不使用超时限制 */
    	COMMTIMEOUTS  CommTimeouts;
    	CommTimeouts.ReadIntervalTimeout = 0;
    	CommTimeouts.ReadTotalTimeoutMultiplier = 0;
    	CommTimeouts.ReadTotalTimeoutConstant = 0;
    	CommTimeouts.WriteTotalTimeoutMultiplier = 0;
    	CommTimeouts.WriteTotalTimeoutConstant = 0;
    	if (bIsSuccess)
    	{
    		bIsSuccess = SetCommTimeouts(m_hComm, &CommTimeouts);
    	}
    
    	DCB  dcb;
    	if (bIsSuccess)
    	{
    		// 将ANSI字符串转换为UNICODE字符串  
    		DWORD dwNum = MultiByteToWideChar(CP_ACP, 0, szDCBparam, -1, NULL, 0);
    		wchar_t *pwText = new wchar_t[dwNum];
    		if (!MultiByteToWideChar(CP_ACP, 0, szDCBparam, -1, pwText, dwNum))
    		{
    			bIsSuccess = TRUE;
    		}
    
    		/** 获取当前串口配置参数,并且构造串口DCB参数 */
    		bIsSuccess = GetCommState(m_hComm, &dcb) && BuildCommDCB(pwText, &dcb);
    		/** 开启RTS flow控制 */
    		dcb.fRtsControl = RTS_CONTROL_ENABLE;
    
    		/** 释放内存空间 */
    		delete[] pwText;
    	}
    
    	if (bIsSuccess)
    	{
    		/** 使用DCB参数配置串口状态 */
    		bIsSuccess = SetCommState(m_hComm, &dcb);
    	}
    
    	/**  清空串口缓冲区 */
    	PurgeComm(m_hComm, PURGE_RXCLEAR | PURGE_TXCLEAR | PURGE_RXABORT | PURGE_TXABORT);
    
    	/** 离开临界段 */
    	LeaveCriticalSection(&m_csCommunicationSync);
    
    	return bIsSuccess == TRUE;
    }
    
    bool CSerialPort::InitPort(UINT portNo, const LPDCB& plDCB)
    {
    	/** 打开指定串口,该函数内部已经有临界区保护,上面请不要加保护 */
    	if (!openPort(portNo))
    	{
    		return false;
    	}
    
    	/** 进入临界段 */
    	EnterCriticalSection(&m_csCommunicationSync);
    
    	/** 配置串口参数 */
    	if (!SetCommState(m_hComm, plDCB))
    	{
    		return false;
    	}
    
    	/**  清空串口缓冲区 */
    	PurgeComm(m_hComm, PURGE_RXCLEAR | PURGE_TXCLEAR | PURGE_RXABORT | PURGE_TXABORT);
    
    	/** 离开临界段 */
    	LeaveCriticalSection(&m_csCommunicationSync);
    
    	return true;
    }
    
    void CSerialPort::ClosePort()
    {
    	/** 如果有串口被打开,关闭它 */
    	if (m_hComm != INVALID_HANDLE_VALUE)
    	{
    		CloseHandle(m_hComm);
    		m_hComm = INVALID_HANDLE_VALUE;
    	}
    }
    
    bool CSerialPort::openPort(UINT portNo)
    {
    	/** 进入临界段 */
    	EnterCriticalSection(&m_csCommunicationSync);
    
    	/** 把串口的编号转换为设备名 */
    	char szPort[50];
    	sprintf_s(szPort, "COM%d", portNo);
    
    	/** 打开指定的串口 */
    	m_hComm = CreateFileA(szPort,  /** 设备名,COM1,COM2等 */
    		GENERIC_READ | GENERIC_WRITE, /** 访问模式,可同时读写 */
    		0,                            /** 共享模式,0表示不共享 */
    		NULL,                         /** 安全性设置,一般使用NULL */
    		OPEN_EXISTING,                /** 该参数表示设备必须存在,否则创建失败 */
    		0,
    		0);
    
    	/** 如果打开失败,释放资源并返回 */
    	if (m_hComm == INVALID_HANDLE_VALUE)
    	{
    		LeaveCriticalSection(&m_csCommunicationSync);
    		return false;
    	}
    
    	/** 退出临界区 */
    	LeaveCriticalSection(&m_csCommunicationSync);
    
    	return true;
    }
    
    bool CSerialPort::OpenListenThread()
    {
    	/** 检测线程是否已经开启了 */
    	if (m_hListenThread != INVALID_HANDLE_VALUE)
    	{
    		/** 线程已经开启 */
    		return false;
    	}
    
    	s_bExit = false;
    	/** 线程ID */
    	UINT threadId;
    	/** 开启串口数据监听线程 */
    	m_hListenThread = (HANDLE)_beginthreadex(NULL, 0, ListenThread, this, 0, &threadId);
    	if (!m_hListenThread)
    	{
    		return false;
    	}
    	/** 设置线程的优先级,高于普通线程 */
    	if (!SetThreadPriority(m_hListenThread, THREAD_PRIORITY_ABOVE_NORMAL))
    	{
    		return false;
    	}
    
    	return true;
    }
    
    bool CSerialPort::CloseListenTread()
    {
    	if (m_hListenThread != INVALID_HANDLE_VALUE)
    	{
    		/** 通知线程退出 */
    		s_bExit = true;
    
    		/** 等待线程退出 */
    		Sleep(10);
    
    		/** 置线程句柄无效 */
    		CloseHandle(m_hListenThread);
    		m_hListenThread = INVALID_HANDLE_VALUE;
    	}
    	return true;
    }
    
    UINT CSerialPort::GetBytesInCOM()
    {
    	DWORD dwError = 0;  /** 错误码 */
    	COMSTAT  comstat;   /** COMSTAT结构体,记录通信设备的状态信息 */
    	memset(&comstat, 0, sizeof(COMSTAT));
    
    	UINT BytesInQue = 0;
    	/** 在调用ReadFile和WriteFile之前,通过本函数清除以前遗留的错误标志 */
    	if (ClearCommError(m_hComm, &dwError, &comstat))
    	{
    		BytesInQue = comstat.cbInQue; /** 获取在输入缓冲区中的字节数 */
    	}
    
    	return BytesInQue;
    }
    
    UINT WINAPI CSerialPort::ListenThread(void* pParam)
    {
    	/** 得到本类的指针 */
    	CSerialPort *pSerialPort = reinterpret_cast<CSerialPort*>(pParam);
    
    	// 线程循环,轮询方式读取串口数据  
    	while (!pSerialPort->s_bExit)
    	{
    		UINT BytesInQue = pSerialPort->GetBytesInCOM();
    		/** 如果串口输入缓冲区中无数据,则休息一会再查询 */
    		if (BytesInQue == 0)
    		{
    			Sleep(SLEEP_TIME_INTERVAL);
    			continue;
    		}
    
    		/** 读取输入缓冲区中的数据并输出显示 */
    		char cRecved = 0x00;
    		do
    		{
    			cRecved = 0x00;
    			if (pSerialPort->ReadChar(cRecved) == true)
    			{
    				std::cout << cRecved;
    				continue;
    			}
    		} while (--BytesInQue);
    	}
    
    	return 0;
    }
    
    bool CSerialPort::ReadChar(char &cRecved)
    {
    	BOOL  bResult = TRUE;
    	DWORD BytesRead = 0;
    	if (m_hComm == INVALID_HANDLE_VALUE)
    	{
    		return false;
    	}
    
    	/** 临界区保护 */
    	EnterCriticalSection(&m_csCommunicationSync);
    
    	/** 从缓冲区读取一个字节的数据 */
    	bResult = ReadFile(m_hComm, &cRecved, 1, &BytesRead, NULL);
    	if ((!bResult))
    	{
    		/** 获取错误码,可以根据该错误码查出错误原因 */
    		DWORD dwError = GetLastError();
    
    		/** 清空串口缓冲区 */
    		PurgeComm(m_hComm, PURGE_RXCLEAR | PURGE_RXABORT);
    		LeaveCriticalSection(&m_csCommunicationSync);
    
    		return false;
    	}
    
    	/** 离开临界区 */
    	LeaveCriticalSection(&m_csCommunicationSync);
    
    	return (BytesRead == 1);
    
    }
    
    bool CSerialPort::WriteData(unsigned char* pData, unsigned int length)
    {
    	BOOL   bResult = TRUE;
    	DWORD  BytesToSend = 0;
    	if (m_hComm == INVALID_HANDLE_VALUE)
    	{
    		return false;
    	}
    
    	/** 临界区保护 */
    	EnterCriticalSection(&m_csCommunicationSync);
    
    	/** 向缓冲区写入指定量的数据 */
    	bResult = WriteFile(m_hComm, pData, length, &BytesToSend, NULL);
    	if (!bResult)
    	{
    		DWORD dwError = GetLastError();
    		/** 清空串口缓冲区 */
    		PurgeComm(m_hComm, PURGE_RXCLEAR | PURGE_RXABORT);
    		LeaveCriticalSection(&m_csCommunicationSync);
    
    		return false;
    	}
    
    	/** 离开临界区 */
    	LeaveCriticalSection(&m_csCommunicationSync);
    
    	return true;
    }


    main.cpp

    int _tmain(int argc, _TCHAR* argv[])  
    {  
     
        CSerialPort mySerialPort;  
     
        if (!mySerialPort.InitPort(2))  
        {  
            std::cout << "initPort fail !" << std::endl;  
        }  
        else 
        {  
            std::cout << "initPort success !" << std::endl;  
        }  
     
        if (!mySerialPort.OpenListenThread())  
        {  
            std::cout << "OpenListenThread fail !" << std::endl;  
        }  
        else 
        {  
            std::cout << "OpenListenThread success !" << std::endl;  
        }  
     
        int temp;  
        std::cin >> temp;  
     
        return 0;  
    }  



    展开全文
  • IT学吧好像关闭了,网上也没找到过源码,自己用vs2013动手写的,经过了测试,希望能给初学者提供参考。

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 11,123
精华内容 4,449
关键字:

c++串口编程

c++ 订阅