Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added tcp support and previous paring ritual - added ev3 tunnel for sending hex bytes directly to ev3 - added a perl script moveEv3.pl that can use the tunneling functionality to control the ev3 remotely (kinda) - bumped GPL v2 to v3 - added ev3 listen for listening on HID packets. size reported is incorrect - added ev3pair.pl which opens a FIFO and passes it as serial port for use with ev3duder over bluetooth
- Loading branch information
Showing
24 changed files
with
758 additions
and
90 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -50,8 +50,7 @@ ev3duder | |
#doxygen | ||
doc | ||
#vim | ||
*.swp | ||
*.swo | ||
*.sw* | ||
*.pyc | ||
|
||
doc/ | ||
|
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,74 @@ | ||
#!/usr/bin/perl | ||
## Pair with ev3 and make VM available as FIFO | ||
#sample usage: | ||
# ./ev3pair.pl ~/ev3.sock & | ||
# ./ev3duder -d ~/ev3.sock ls | ||
use IO::Socket::INET; | ||
use IO::Select; | ||
use warnings; | ||
|
||
my $data; | ||
my ($udp_port, $ev3_addr, $tcp_port, $serial); | ||
|
||
$FIFO_NAME = $ARGV[0] // "$ENV{HOME}/ev3.sock"; | ||
|
||
$sock=IO::Socket::INET->new(Proto => 'udp', | ||
LocalPort => 3015) | ||
or die "Can't bind: $@\n"; | ||
|
||
if($sock->recv($data, 128)) { | ||
($udp_port, $ipaddr) = sockaddr_in($sock->peername); | ||
$ev3_addr = inet_ntoa($ipaddr); | ||
} | ||
if ($data =~ /^ | ||
Serial-Number:\ ([[:xdigit:]]+)\r\n | ||
Port:\ (\d+)\r\n | ||
Name:\ (.*?)\r\n | ||
Protocol:\ (.*?)\r\n | ||
$/x) | ||
{ | ||
($serial, $tcp_port, $ev3_name, $proto) = ($1,$2,$3,$4); | ||
print STDERR "$ev3_name ($serial) @ $proto://$ev3_addr:$tcp_port\n"; | ||
} | ||
$ev3 = IO::Socket::INET->new( | ||
Proto => 'udp', | ||
PeerPort => $udp_port, | ||
PeerAddr => $ev3_addr, | ||
) or die "Could not create socket: $@\n"; | ||
|
||
$sock->send("\x00") or die "Send error: $!\n"; | ||
$ev3->close(); | ||
|
||
$ev3 = new IO::Socket::INET ( | ||
Proto => 'tcp', | ||
PeerHost => $ev3_addr, | ||
PeerPort => $tcp_port, | ||
) or die "Can't bind : $@\n"; | ||
#$serial =~ s/./1/g; # strangely, this works. | ||
$ev3->send("GET /target?sn=$serial VMTP1.0\nProtocol: $proto"); | ||
print STDERR <$ev3> . "\n"; | ||
|
||
require POSIX; | ||
POSIX::mkfifo($FIFO_NAME."in", 0666) or die "can't mkfifo $FIFO_NAME: $!"; | ||
POSIX::mkfifo($FIFO_NAME."out", 0666) or die "can't mkfifo $FIFO_NAME: $!"; | ||
open($fifoin, "<", $FIFO_NAME . "in") or die "couldn't open fifo: $!"; | ||
open($fifoout, ">", $FIFO_NAME. "out") or die "couldn't open fifo: $!"; | ||
print $FIFO_NAME . "(in|out) online...\n"; | ||
%pair = ($ev3 => "fifoout", $fifoin => "ev3"); | ||
my $sel = IO::Select->new($ev3, $fifoin); | ||
while (@ready = $sel->can_read) | ||
{ | ||
my $buffer; | ||
foreach $fh (@ready) { | ||
$read = $fh->sysread($buffer, 1337) or die "couldn't read: $@"; | ||
#$written = ${$pair{$fh}}->syswrite($buffer); # why does this duplicate? | ||
#print "$written/$read bytes sent to ", $pair{$fh}, "\n"; | ||
#$buffer = <$fh>; | ||
no warnings; print ${$pair{$fh}} $buffer; use warnings; | ||
print length $buffer , " bytes sent to ", $pair{$fh}, "\n"; | ||
} | ||
} | ||
$sel->remove($ev3, $fifoin); | ||
close($fifoin), close($fifoout), shutdown($ev3, 2), close($ev3); | ||
unlink $FIFO_NAME."in", $FIFO_NAME."out"; # Why can't I write $ARGV[0] here? | ||
|
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,35 @@ | ||
#!/usr/bin/perl | ||
|
||
use Curses; | ||
use IPC::Open2; | ||
print open2(\*EV3OUT, \*EV3IN, "ev3 tunnel") or die "couldn't find: %!"; | ||
|
||
my $ch = 0; | ||
initscr, noecho, cbreak; | ||
eval { keypad(1) }; | ||
addstr(0, 0, "press an arrow key on your keyboard: "); | ||
refresh(); | ||
while (1) | ||
{ | ||
$ch = getch(); | ||
addstr(2, 0, " "); | ||
if ($ch == KEY_UP) { addstr(2, 0, "KEY_UP"); | ||
print EV3IN "0C00xxxx8000 00 A4 00 09 50 A6 00 09\n"; | ||
} | ||
elsif ($ch == KEY_DOWN) { addstr(2, 0, "KEY_DOWN"); | ||
print EV3IN "0900xxxx8000 00 A3 00 09 00\n"; | ||
} | ||
elsif ($ch == KEY_LEFT) { addstr(2, 0, "KEY_LEFT"); | ||
print EV3IN "0900xxxx8000 00 A3 00 09 00\n"; | ||
print EV3IN "0C00xxxx8000 00 A4 00 08 50 A6 00 08\n"; | ||
} | ||
elsif ($ch == KEY_RIGHT) { addstr(2, 0, "KEY_RIGHT"); | ||
print EV3IN "0900xxxx8000 00 A3 00 09 00\n"; | ||
print EV3IN "0C00xxxx8000 00 A4 00 01 50 A6 00 01\n"; | ||
} | ||
refresh; | ||
} | ||
END {endwin} | ||
sub motor | ||
{ | ||
} |
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
Oops, something went wrong.