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