Commit Graph

222 Commits

Author SHA1 Message Date
Paul Sokolovsky cfc94bec9f extmod/modlwip: Implement sendall() method for TCP sockets. 2016-05-03 10:43:11 +03:00
Paul Sokolovsky b8468d12a1 extmod/modwebrepl: Get rid of using strncpy(). 2016-05-02 20:52:34 +03:00
Paul Sokolovsky 859e4e94f3 extmod/modwebrepl: Add support for password.
Request for password then becomes mandatory part of the protocol.
2016-04-30 20:36:32 +03:00
Paul Sokolovsky 18775d3807 extmod/modwebrepl: Set debugging by default to off.
That's production setting. Also, extra UART output may affect behavior of
(subpar) network drivers.
2016-04-29 19:17:37 +03:00
Paul Sokolovsky b0f3ae58e7 extmod/modwebrepl: Add rate-limiting workaround for broken network drivers.
Like ESP8266 has.
2016-04-29 19:14:03 +03:00
Paul Sokolovsky 8811b0af9c extmod/modwebrepl: Use bigger socket receive buffer.
The smaller chunks we send (and receive), the more packets there to
receive, and higher chance to git internal packet buffer overflow in
WiFi driver.
2016-04-29 18:43:19 +03:00
Paul Sokolovsky b3bc2ee1b9 extmod/modwebrepl: More detailed debug output.
So detailed that even commented by default.
2016-04-29 17:37:40 +03:00
Paul Sokolovsky 473b639845 extmod/modwebrepl: GET_FILE: Send length-prefix chunk with one write().
A bit of optimization.
2016-04-29 17:35:21 +03:00
Paul Sokolovsky f41e1f1bb7 extmod/modwebrepl: Keep reading data when there's something to read.
EAGAIN should be returned only if underlying socket returned it. Wrap
existing read function into external loop to process all data available.
2016-04-29 01:05:02 +03:00
Paul Sokolovsky 6514ff6160 extmod/modwebrepl: Initial implementation of "get file" operation. 2016-04-29 01:02:39 +03:00
Paul Sokolovsky 25d0f7d59d extmod/modwebrepl: Module to handle WebREPL protocol.
While just a websocket is enough for handling terminal part of WebREPL,
handling file transfer operations requires demultiplexing and acting
upon, which is encapsulated in _webrepl class provided by this module,
which wraps a websocket object.
2016-04-29 00:52:52 +03:00
Paul Sokolovsky ba61480df5 extmod/modussl: SSL_OK from ssl_read() means "no user data so far".
SSL_OK is numeric 0, and it's *not* an EOF. So, should keep reading.
2016-04-28 17:29:11 +03:00
Paul Sokolovsky 2534bfdb92 extmod/modussl: Support server-side SSL sockets.
wrap_socket(sock, server_side=True)
2016-04-28 17:27:20 +03:00
Paul Sokolovsky d54290f6e2 extmod/modussl: Throw Python exceptions in case of errors. 2016-04-28 00:49:54 +03:00
Paul Sokolovsky 480c212009 extmod/modwebsocket: Handle CLOSE control frame.
This fixes situation when clients hangs waiting for disconnect and does
so only on timeout.
2016-04-27 12:49:30 +03:00
Paul Sokolovsky 1c6d91d968 extmod/modlwip: Add print_pcbs() debug function.
This requires lwIP built with LWIP_DEBUG (or it will be no-op).
2016-04-26 16:30:13 +03:00
Damien George 45ac5a85d5 extmod/modlwip: Workaround esp8266 sendto issue where 1 is returned. 2016-04-26 13:19:08 +01:00
Damien George a63542387d extmod, stmhal: Fix typo of macro that detects if float is enabled. 2016-04-26 12:47:24 +01:00
Paul Sokolovsky 7a012f4793 extmod/modlwip: Protect recv/accept Python callback against exceptions.
Using usual call_function_*_protected() helper, to avoid NLR jump crashes.
2016-04-25 21:27:55 +03:00
Damien George 624738ca64 extmod/machine_i2c: Allow mp_hal_pin_obj_t to be any type, not a ptr. 2016-04-22 09:56:02 +01:00
Paul Sokolovsky 7d57037906 extmod/modlwip: Add ability to run callback on "recv" and "accept" events.
To use: .setsockopt(SOL_SOCKET, 20, lambda sock: print(sock)). There's a
single underlying callback slot. For normal sockets, it serves as data
received callback, for listening sockets - connection arrived callback.
2016-04-17 18:06:45 +03:00
Paul Sokolovsky 8007f84cca extmod/modlwip: lwip_tcp_receive(): Full error handling. 2016-04-17 02:22:26 +03:00
Paul Sokolovsky b830f4c610 extmod/modlwip: lwip_tcp_send(): Full error handling. 2016-04-17 02:20:05 +03:00
Damien George bcd719ea3a extmod/fsusermount: In mount/mkfs, deregister VFS object on error.
Should fix issue #1947.
2016-04-14 23:36:25 +01:00
Paul Sokolovsky 5c1af60e19 extmod/modlwip: More debug messages for various edge conditions. 2016-04-15 00:37:12 +03:00
Paul Sokolovsky 44ab5c3ef1 extmod/modlwip: Start adding debug output. 2016-04-14 01:15:52 +03:00
Paul Sokolovsky fef0d9818a extmod/modlwip: lwip_tcp_receive(): Properly handle EOF for non-blocking sock. 2016-04-14 00:59:09 +03:00
Paul Sokolovsky 59a4fee516 extmod/modwebsocket: Another case to propagate EOF. 2016-04-13 22:17:09 +03:00
Paul Sokolovsky 54ea253f56 extmod/moduos_dupterm: Don't swallow exceptions in dupterm's read()/write().
The idea is that if dupterm object can handle exceptions, it will handle
them itself. Otherwise, object state can be compromised and it's better
to terminate dupterm session. For example, disconnected socket will keep
throwing exceptions and dump messages about that.
2016-04-13 16:34:11 +03:00
Damien George eec8a94f04 extmod/machine_i2c: Implement I2C memory reading/writing. 2016-04-12 15:52:17 +01:00
Damien George 9314b2df4f extmod/machine_i2c: Fix I2C reading by sending ack/nack at end of byte. 2016-04-12 15:46:13 +01:00
Damien George d083712224 extmod: Add generic machine.I2C class, with bit-bang I2C.
Should work on any machine that provides the correct pin functions.
2016-04-12 14:06:54 +01:00
Damien George 53ad681ed1 extmod: Add initial framebuf module. 2016-04-12 14:06:53 +01:00
Paul Sokolovsky f8fb4470a0 extmod/modwebsocket: write(): Support write size beyond 125 bytes. 2016-04-11 14:07:57 +03:00
Paul Sokolovsky 7063210014 extmod/modlwip: Fix for loss of data in unaccepted incoming sockets.
When lwIP creates a incoming connection socket of a listen socket, it
sets its recv callback to one which discards incoming data. We set
proper callback only in accept() call, when we allocate Python-level
socket where we can queue incoming data. So, in lwIP accept callback
be sure to set recv callback to one which tells lwIP to not discard
incoming data.
2016-04-11 01:21:34 +03:00
Paul Sokolovsky b69f798c92 extmod/modwebsocket.h: Split websocket-related defines for reuse. 2016-04-10 13:42:51 +03:00
Paul Sokolovsky d6236e85c2 extmod/modwebsocket: Implement MP_STREAM_SET_DATA_OPTS ioctl.
Allows to set fragment type (txt/bin/etc.) for output records.
2016-04-10 13:19:26 +03:00
Paul Sokolovsky 6837dba6b8 extmod/modwebsocket: Allow to get type of last read data using ioctl(). 2016-04-10 12:50:46 +03:00
Paul Sokolovsky f38e8f5217 extmod/modwebsocket: Record current fragment type (binary/text/etc.)
Also, handle continuation frames (untested).
2016-04-09 16:14:47 +03:00
Paul Sokolovsky 5b1c221785 extmod/modwebsocket: Add option for blocking writes to non-blk sockets.
This is strange asymmetry which is sometimes needed, e.g. for WebREPL: we
want to process only available input and no more; but for output, we want
to get rid of all of it, because there's no other place to buffer/store
it. This asymmetry is akin to CPython's asyncio asymmetry, where reads are
asynchronous, but writes are synchronous (asyncio doesn't expect them to
block, instead expects there to be (unlimited) buffering for any sync write
to completely immediately).
2016-04-09 16:03:38 +03:00
Paul Sokolovsky 397b705647 extmod/modwebsocket: Reset mask between packets. 2016-04-09 12:29:18 +03:00
Paul Sokolovsky 7e9182f3aa extmod/modwebsocket: Make sure to propagate EOF. 2016-04-08 20:26:54 +03:00
Tom Sparks 20d9bc2d76 extmod/modure: re_exec() renamed to ure_exec() due to collison in 4.3BSD.
Addresses issue #1972.
2016-04-08 20:12:03 +03:00
Paul Sokolovsky 05ba2433f6 extmod/modwebsocket: Properly check number of args to constructor. 2016-04-08 16:05:48 +03:00
Paul Sokolovsky 651a188299 extmod/vfs_fat_diskio: Actually support sectors != 512 with Python blockdevs. 2016-03-27 14:21:06 +03:00
Paul Sokolovsky 91031a75a1 extmod/modlwip: lwip_socket_setsockopt: Handle option value properly. 2016-03-25 20:53:52 +02:00
Paul Sokolovsky 4332d72fd8 extmod/modlwip: Add lwip->POSIX error map for lwIP 1.4.0.
Between 1.4.0 and 1.4.1, lwIP errors were renumbered.
2016-03-25 20:32:01 +02:00
Paul Sokolovsky de0c84ebf1 extmod/modlwip: lwip_tcp_send: Handle properly send buffer full condition.
Per POSIX http://pubs.opengroup.org/onlinepubs/9699919799/functions/send.html :
"If space is not available at the sending socket to hold the message to be
transmitted, and the socket file descriptor does not have O_NONBLOCK set,
send() shall block until space is available. If space is not available at the
sending socket to hold the message to be transmitted, and the socket file
descriptor does have O_NONBLOCK set, send() shall fail [with EAGAIN]."
2016-03-25 18:38:13 +02:00
Paul Sokolovsky 5e75f335e6 extmod/modlwip: Implement setsocketopt(SO_REUSEADDR). 2016-03-25 17:44:24 +02:00
Paul Sokolovsky 8f1854ad2d extmod/modlwip: Add SOL_SOCKET and SO_REUSEADDR constants for setsockopt(). 2016-03-25 15:06:12 +02:00