usb串口編程
㈠ linuxusb涓插彛椹卞姩linuxusb涓插彛
濡備綍鍦╨inux涓嬪湪搴旂敤灞傚緱鍒癠SB璁懼囧悕縐頒俊鎮錛
鍏堣幏鍙栦竴涓/dev鐨勫垪琛錛岀劧鍚庡緱鍒版彃鎾浜嬩歡鍚庯紝鍦ㄨ幏鍙栦竴涓嬪綋鍓嶇殑/dev鍒楄〃錛岀劧鍚庡仛涓涓嬫瘮杈僱inux緋葷粺浼氳嚜鍔ㄨ瘑鍒玌SB鎺ュ彛涓轟覆鍙g佺洏sda(閫氬父涓簊da1錛屽彲閫氳繃fdisk-l鍛戒護鏌ヨ)錛屾寕杞藉氨鍙鐢ㄣ備緥錛氭柊寤烘寕杞界洰褰昺kdir/mnt/usb錛屾寕杞絤ount/dev/sda1/mnt/usb錛岀敤瀹屽嵏杞芥寕璧風偣unmount/dev/sda1/mnt/usb銆
濡備綍鏌ョ湅linux涓嬩覆鍙f槸鍚﹀彲鐢?涓插彛鍚嶇О絳夛紵
1銆佹煡鐪嬩覆鍙f槸鍚﹀彲鐢錛屽彲浠ュ逛覆鍙e彂閫佹暟鎹姣斿傚筩om1鍙o紝echolyjie126>/dev/ttyS0
2銆佹煡鐪嬩覆鍙e悕縐頒嬌鐢╨s-l/dev/ttyS*涓鑸鎯呭喌涓嬩覆鍙g殑鍚嶇О鍏ㄩ儴鍦╠ev涓嬮潰錛屽傛灉浣犳病鏈夊栨彃涓插彛鍗$殑璇濋粯璁ゆ槸dev涓嬬殑ttyS*,涓鑸瑃tyS0瀵瑰簲com1錛宼tyS1瀵瑰簲com2錛屽綋鐒朵篃涓嶄竴瀹氭槸蹇呯劧鐨勶紱
3銆佹煡鐪嬩覆鍙i┍鍔錛歝at/proc/tty/drivers/serial
4銆佹煡鐪嬩覆鍙h懼囷細dmesg|grepttyS*
LinuxRS485涓插彛緙栫▼錛
瀵逛簬緙栫▼鏉ヨ達紝娌′粈涔堝尯鍒錛岄氳繃鎺у埗485鐨勪嬌鑳界璇ョ▼搴忓畬鍏ㄥ彲浠ヤ嬌鐢ㄣ傚敮涓鐨勫尯鍒灝辨槸浣犲湪鍙戦佺殑鏃跺欓氳繃紼嬪簭鎶485鐨勬帶鍒惰剼鎷夐珮錛屾帴鏀剁殑鏃跺欐妸浠栨媺浣庡氨鍙浠ヤ簡銆傝嚦浜庣數姘旀柟闈㈢殑鍖哄埆錛歊S232鏄鍏ㄥ弻宸ワ紝鍙浠ュ悓鏃舵敹鍙戱紝RS485鏄鍗婂弻宸ワ紝涓嶈兘鍚屾椂鏀跺彂錛岃繕鏈夌數騫充俊鍙蜂笉涓鏍鳳紝榪欎釜緙栫▼浣犲氨涓嶈佺悊浜嗐
涓婁綅鏈簂abview鎬庝箞閫氳繃涓插彛鎺ユ敹涓嬩綅鏈哄彂鏉ョ殑鏁版嵁騫惰繘琛屽勭悊錛
鏂規硶涓鎵句釜浠鍣錛堢ず娉㈠櫒錛宒aq錛夎葷數騫蟲椂搴忚嚜宸辮В鏋愶紝鏂規硶浜屾壘涓猧2c鐨勮漿鎹㈣姱鐗囪漿涓插彛鎴杣sb鎴栬呰姱鐗囨彁渚沝ll錛屾柟娉曚笁鎼炰釜鍗曠墖鏈鴻嚜宸卞啓涓嬩綅鏈鴻В鏋愭椂搴忓啀鐢ㄤ覆鍙d紶鍒扮數鑴戱紝鏂規硶鍥涙壘涓鍙板甫i2c妯″潡鐨勪富鏈虹劧鍚庤皟鐢╳in_api錛圠inux灝變笉鐭ラ亾浜嗭級r
linux鏌ユ壘涓插彛錛
1銆佽懼囧叆鍙 鍙浠ユ煡/dev/ttyS*銆/dev/*uart*錛堜富璁懼囧彿4鎴栬204錛夛紝絎涓涓插彛涓鑸涓簍tyS0銆*uart0絳 USB杞涓插彛璁懼囦竴鑸涓/dev/ttyUSB*(涓昏懼囧彿188)錛岀涓鍙d竴鑸涓簍tyUSB0 2銆佷互涓/dev涓嬪彧鏄涓插彛鐨勫叆鍙o紝鍏蜂綋璁懼囧瓨鍦ㄤ笌鍚﹂渶瑕佹寜鍏抽敭瀛楋紙ttyS銆乼tyUSB銆乽art錛夋煡璇/proc/devices浠ョ『瀹氥 3銆佷覆鍙d負閫氳絝鍙o紝鏈夊氫釜涓插彛璁懼囨椂錛岃佺『瀹氭e湪琚榪炴帴鐨勪覆鍙f槸鍝涓錛岄渶瑕佹嫻嬩竴涓嬶紝濡傦細 cat/dev/ttyS0