forked from mik3y/usb-serial-for-android
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build tools update; instrumented device test
- Loading branch information
1 parent
d967bb6
commit 9431344
Showing
12 changed files
with
1,032 additions
and
31 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Tue Jun 23 00:11:28 EDT 2015 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip | ||
#Thu Oct 26 20:06:55 CEST 2017 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
bridge USB-serial to hardware-serial | ||
for Arduinos based on ATmega32u4 (Leonardo and compatible Pro Micro, Micro) | ||
hardware serial is configured with baud-rate, databits, stopbits, parity as send over USB | ||
see https://github.com/arduino/Arduino/tree/master/hardware/arduino/avr/cores/arduino | ||
-> CDC.cpp|HardwareSerial.cpp for serial implementation details | ||
this sketch is mainly for demonstration / test of CDC communication | ||
performance as real usb-serial bridge would be inacceptable as each byte is send in separate USB packet | ||
*/ | ||
|
||
uint32_t baud = 9600; | ||
uint8_t databits = 8; | ||
uint8_t stopbits = 1; | ||
uint8_t parity = 0; | ||
|
||
void setup() { | ||
Serial.begin(baud); // USB | ||
Serial1.begin(baud, SERIAL_8N1); | ||
} | ||
|
||
void loop() { | ||
// show USB connected state | ||
if (Serial) TXLED1; | ||
else TXLED0; | ||
|
||
// configure hardware serial | ||
if (Serial.baud() != baud || | ||
Serial.numbits() != databits || | ||
Serial.stopbits() != stopbits || | ||
Serial.paritytype() != parity) { | ||
baud = Serial.baud(); | ||
databits = Serial.numbits(); | ||
stopbits = Serial.stopbits(); | ||
parity = Serial.paritytype(); | ||
uint8_t config = 0; // ucsrc register | ||
switch (databits) { | ||
case 5: break; | ||
case 6: config |= 2; break; | ||
case 7: config |= 4; break; | ||
case 8: config |= 6; break; | ||
default: config |= 6; | ||
} | ||
switch (stopbits) { | ||
case 2: config |= 8; | ||
// 1.5 stopbits not supported | ||
} | ||
switch (parity) { | ||
case 1: config |= 0x30; break; // odd | ||
case 2: config |= 0x20; break; // even | ||
// mark, space not supported | ||
} | ||
Serial1.end(); | ||
Serial1.begin(baud, config); | ||
} | ||
|
||
// bridge | ||
if (Serial.available() > 0) | ||
Serial1.write(Serial.read()); | ||
if (Serial1.available() > 0) | ||
Serial.write(Serial1.read()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
*** /n/archiv/python/rfc2217_server.py 2018-03-10 09:02:07.613771600 +0100 | ||
--- rfc2217_server.py 2018-03-09 20:57:44.933717100 +0100 | ||
*************** | ||
*** 26,31 **** | ||
--- 26,32 ---- | ||
self, | ||
logger=logging.getLogger('rfc2217.server') if debug else None) | ||
self.log = logging.getLogger('redirector') | ||
+ self.dlog = logging.getLogger('data') | ||
|
||
def statusline_poller(self): | ||
self.log.debug('status line poll thread started') | ||
*************** | ||
*** 55,60 **** | ||
--- 56,62 ---- | ||
try: | ||
data = self.serial.read(self.serial.in_waiting or 1) | ||
if data: | ||
+ self.dlog.debug("serial read: "+data.encode('hex')) | ||
# escape outgoing data when needed (Telnet IAC (0xff) character) | ||
self.write(b''.join(self.rfc2217.escape(data))) | ||
except socket.error as msg: | ||
*************** | ||
*** 76,81 **** | ||
--- 78,84 ---- | ||
data = self.socket.recv(1024) | ||
if not data: | ||
break | ||
+ self.dlog.debug("socket read: "+data.encode('hex')) | ||
self.serial.write(b''.join(self.rfc2217.filter(data))) | ||
except socket.error as msg: | ||
self.log.error('{}'.format(msg)) | ||
*************** | ||
*** 132,137 **** | ||
--- 135,141 ---- | ||
logging.basicConfig(level=logging.INFO) | ||
#~ logging.getLogger('root').setLevel(logging.INFO) | ||
logging.getLogger('rfc2217').setLevel(level) | ||
+ logging.getLogger('data').setLevel(level) | ||
|
||
# connect to serial port | ||
ser = serial.serial_for_url(args.SERIALPORT, do_not_open=True) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.hoho.android.usbserial" | ||
android:versionCode="1" | ||
android:versionName="1.0"> | ||
<uses-permission android:name="android.permission.INTERNET"/> | ||
</manifest> |
Oops, something went wrong.