forked from c4ev3/ev3duder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug: CloseHandle doesn't close serial port immidiately
- Loading branch information
Showing
14 changed files
with
154 additions
and
9 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 |
---|---|---|
@@ -1 +1 @@ | ||
.. | ||
COM3 |
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,9 @@ | ||
/** @file cat.sh | ||
* @brief cat(1) wrapper for cat'ing to the ev3 LCD | ||
* @author Ahmad Fatoum | ||
*/ | ||
|
||
int main(void) | ||
{ | ||
|
||
} |
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,21 @@ | ||
#!/bin/sh | ||
|
||
## @file cat.sh | ||
## cat(1) wrapper for cat'ing to the ev3 LCD | ||
## calls cat on input, builds a bytecode executable | ||
## and pipes it to the VM via netcat | ||
## @author Ahmad Fatoum | ||
|
||
#consts | ||
LINE_WIDTH = 20 | ||
|
||
|
||
CAT = "$(cat $@)" | ||
|
||
IFS = '\n' read -ra LINE <<< "$IN" | ||
for i in "${LINE[@]}"; do | ||
# loop for each < LINE_WIDTH | ||
# generate bytecode | ||
|
||
done | ||
|
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
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,45 @@ | ||
/** | ||
* @file io.c - Input/Output wrappers for Bluetooth (Win32) | ||
* @author Ahmad Fatoum | ||
* @license Code available under terms of the GNU General Public License | ||
*/ | ||
#include <stdlib.h> | ||
#include <errno.h> | ||
|
||
#include <windows.h> | ||
|
||
#include "defs.h" | ||
|
||
#define BT L"COM1" | ||
|
||
// ^ TODO: add multiple COM ports | ||
void *bt_open(const wchar_t *device) | ||
{ | ||
HANDLE handle = CreateFileW(device ?: BT, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); | ||
return handle != INVALID_HANDLE_VALUE ? handle : NULL; | ||
} | ||
|
||
int bt_write(void* handle, const u8* buf, size_t count) | ||
{ | ||
DWORD dwBytesWritten; | ||
|
||
buf++;count--; // omit HID report number | ||
if (!WriteFile(handle, buf, count, &dwBytesWritten, NULL)) | ||
return -1; | ||
|
||
return dwBytesWritten; | ||
} | ||
int bt_read(void *handle, u8* buf, size_t count, int milliseconds) | ||
{ | ||
(void) milliseconds; // https://msdn.microsoft.com/en-us/library/windows/desktop/aa363190%28v=vs.85%29.aspx | ||
DWORD dwBytesRead; | ||
if (!ReadFile(handle, buf, count, &dwBytesRead, NULL)) | ||
return -1; | ||
return dwBytesRead; | ||
} | ||
void bt_close(void *handle) | ||
{ | ||
CloseHandle(handle); | ||
} | ||
const wchar_t *bt_error(void* fd_) { (void)fd_; return L"Errors not implemented yet";} | ||
|
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,25 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
#include "ev3_io.h" | ||
|
||
#include "defs.h" | ||
#include "systemcmd.h" | ||
#include "error.h" | ||
#include "funcs.h" | ||
|
||
/** | ||
* @brief Concatenate files to the LCD screen. | ||
* @param [in] path remote FILE*s | ||
* @param [in] count number of FILE*s to cat | ||
* | ||
* @retval error according to enum #ERR | ||
* @see http://topikachu.github.io/python-ev3/UIdesign.html | ||
*/ | ||
#define MAX_READ 1024 | ||
extern int cat(const char *rem, size_t count) | ||
{ | ||
|
||
|
||
} |
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
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,20 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <assert.h> | ||
|
||
#include <windows.h> | ||
#include "src/btserial.h" | ||
static const unsigned char tone[] = "\x0\x0F\x00\0\0\x80\x00\x00\x94\x01\x81\x02\x82\xE8\x03\x82\xE8\x03"; | ||
|
||
#define MAX_STR 256 | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
HANDLE handle = bt_open(L"COM3"); | ||
int written = bt_write(handle, tone, sizeof tone - 1); | ||
CloseHandle(handle); | ||
printf("Wrote %d bytes of %u", written, sizeof tone-1); | ||
return 0; | ||
} | ||
|