main.c

来自「PTZ云台控制code,实用与所有的云台控制」· C语言 代码 · 共 74 行

C
74
字号
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>

#include "ptzimpl.h"
int main(void){

	/*int tty0,tty1,ss0,ss1;
     
	 if( (tty0=open("/dev/ttyS0", O_RDWR | O_NOCTTY)) < 0 )
	{
		printf("ERROR. Open ttyS0 device...\n");		
		//return -1;
	}
	else
		printf("OK. Open ttyS0 device...\n");

	close(tty0);
	 if( (tty1=open("/dev/ttyS1", O_RDWR | O_NOCTTY)) < 0 )
	{
		printf("ERROR. Open ttyS1 device...\n");		
		//return -1;
	}
	else
		printf("OK. Open ttyS1 device...\n");
	close(tty1);
	if( (ss0=open("/dev/tts/2", O_RDWR | O_NOCTTY)) < 0 )
	{
		printf("ERROR. Open ss2 device...\n");		
		//return -1;
	}
	else
		printf("OK. Open ss2 device...\n");
	close(ss0);
	if( (ss1=open("/dev/tts/3", O_RDWR | O_NOCTTY)) < 0 )
	{
		printf("ERROR. Open ss3 device...\n");		
		//return -1;
	}
	else
		printf("OK. Open ss3 device...\n");
	close(ss1);

	/*while(1){
		printf("echo test > /dev/tts/1\n");
		system("echo 1000> /dev/tts/1");
		system("echo 1000> /dev/ttyS1");
		//usleep(10000);
	}*/
	if( Init485() != 0 )
	{
		printf("ERROR. Init 485\n");
		return -1;
	}
	
      int i=20;
	while(1){
	
	DeviceControl(i);
	if(i==0)
	i=20;
	else i--;
	sleep(1);
	}
	
	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?