程序如下:importfcntlimportosimporttimefromstructimport*#ConstantsINPUT='0'OUTPUT='1'PWM_FREQ=520#Pinnumberdir_pin=2pwm_pin=3pwm_value=255#FilelocationsMODE_FILE='/sys/de...

程序如下:

import fcntl

import os

import time

from struct import *

# Constants

INPUT = '0'

OUTPUT = '1'

PWM_FREQ = 520

# Pin number

dir_pin = 2

pwm_pin = 3

pwm_value = 255

# File locations

MODE_FILE = '/sys/devices/virtual/misc/gpio/mode/gpio' + str(dir_pin)

PIN_FILE = '/sys/devices/virtual/misc/gpio/pin/gpio' + str(dir_pin)

PWM_FILE = '/dev/pwmtimer'

# Pin mode

os.system('echo ' + OUTPUT + ' > ' + MODE_FILE)

# Configure PWM

with open(PWM_FILE, 'wb') as f:

pwm_struct = pack('iiiI', pwm_pin, 0, 0, PWM_FREQ)

fcntl.ioctl(f, 0xfa, pwm_struct)

# Motor control

def drive_motor(dir, pwm):

# Set direction

os.system('echo ' + str(dir) + ' > ' + PIN_FILE)

# Output PWM to motor

with open(PWM_FILE, 'wb') as f:

pwm_struct = pack('ii', pwm_pin, pwm)

fcntl.ioctl(f, 0x19, pwm_struct)

# Do stuff with the motor

drive_motor(0, 0)

time.sleep(1)

drive_motor(0, 200)

time.sleep(2)

drive_motor(0, 0)

time.sleep(0.5)

drive_motor(1, 255)

time.sleep(2)

drive_motor(0, 0)

展开

python出现invalid argument什么意思_python程序运行后提示IOError: [Errno 22] Invalid argument 急啊!!!!...相关推荐

  1. python在windows command下打印中文出错 IOError [Errno 22] Invalid argument

    问题描述: python版本:2.7.15 pycharm的python版本:2.7.15 python文件编码:utf-8 windows command编码已经通过执行chcp 65001改为了u ...

  2. python保存创建文件报错 with open(fileName,‘w‘) as fp: IOError: [Errno 22] invalid mode (‘w‘) or filename

    原因:python2.7保存文件时文件名中含有中文 改为:fileName.decode('utf-8')即可 with open(fileName.decode('utf-8'),'w') as f ...

  3. PythonIOError: [Errno 22] invalid mode ('r') or filename

    每次我们需要指导一个文件具体路径得时候,有一部分人喜欢直接用windows得右键文件->属性->安全信息,然后粘贴复制,如下图: 在有一些编辑器看起来时没有任何问题,如下图: 然后运行就会 ...

  4. 在使用python语言的open函数时,提示错误OSError: [Errno 22] Invalid argument: ‘文件路径’

    如题,在使用python语言的open函数时,提示错误OSError: [Errno 22] Invalid argument: '文件路径',在查阅了大量资料后也得到了一些解决方案,但是这些解决方案 ...

  5. Python OSError: [Errno 22] Invalid argument:的出现和解决

    1.在学习从文件读取数据中,写了个示例代码,读取不在同一个目录的file.txt,运行后报这个Python OSError: [Errno 22] Invalid argument:错误: (1).首 ...

  6. python中遇到报错OSError: [Errno 22] Invalid argument的解决方法

    将时间戳用python语言转换成指定日期: 代码如下: import timetimeStamp = 1589018284000 timeArray = time.localtime(timeStam ...

  7. python在使用绝对路径时出现OSError: [Errno 22] Invalid argument: ‘E:\python\python扩展\text_file\pi_digits.txt

    今天我在练习python文件的绝对路径时发现OSError: [Errno 22] Invalid argument: 'E:\python\python扩展\text_file\pi_digits. ...

  8. Python错误集锦:打开文件路径提示参数无效,OSError: [Errno 22] Invalid argument: ‘D:\juzicode\桔子code\readme.txt’

    原文链接:http://www.juzicode.com/archives/2493 错误提示: 打开文件路径提示参数无效:OSError: [Errno 22] Invalid argument: ...

  9. python中invalid argument_Python创建文件报错OSError:[Errno 22] Invalid argument处理

    问题: windows平台下使用python open函数w模式打开文件报错"OSError: [Errno 22] Invalid argument: '../news/"消费升 ...

最新文章

  1. C++中STL中的大、小、相等概念
  2. Nginx http和反向代理配置实例介绍
  3. vb 搜索指定目录下的指定类型文件
  4. 【简易教程】基于Vue-cli使用eslint指南
  5. ASP.NET Core quot;完整发布,自带运行时quot; 到jexus
  6. 函数:MySQL中字符串匹配函数LOCATE和POSITION使用方法
  7. *p++和*++p_2020年P气瓶充装新版试题及P气瓶充装找答案
  8. 电子计算机发展为第五代,电子计算机的发展历程是怎样的?
  9. 超详细汇总21个mysql优化实践【收藏版MySQL优化】
  10. 【学习笔记】深入理解js原型和闭包(13)——【作用域】和【上下文环境】
  11. 基于php和服务器推技术的web即时聊天系统,基于php和服务器推技术的Web即时聊天系统-计算机系统应用.PDF...
  12. 使用ffmpeg对视频、音频进行分离
  13. Citrix 桌面云 XenApp_XenDesktop_7.18 部署
  14. 自定义Qml控件:ImageButton
  15. 彻底卸载VS2015
  16. 用户访谈与问卷调查怎么做
  17. 【算法】生成n个互异随机数的初步算法
  18. 实验二 Linux下Vi编辑器的使用
  19. java多个文件压缩打包成zip下载
  20. 智课雅思词汇---二十五、-ate

热门文章

  1. 淘宝怎么查询商品历史价格信息?item_history_price-获取商品历史价格信息
  2. 中国特种电缆市场市场需求预测及竞争战略研究报告2021年版
  3. Autodesk AutoCAD 2022中文下载及教程
  4. 修改信息时,省级联动问题记录
  5. Kendo-UI学习 下拉列表kendoDropDownList 三级联动demo
  6. Java基础之数据导入
  7. 3.12信号概述(第二阶段)
  8. TIZEN 系统的演化
  9. 微信分享显示分享标题及小图标 前端代码
  10. Bacnet IP协议和Java实现