{"action":"created","issue":{"url":"https://api.github.com/repos/micropython/micropython/issues/1517","labels_url":"https://api.github.com/repos/micropython/micropython/issues/1517/labels{/name}","comments_url":"https://api.github.com/repos/micropython/micropython/issues/1517/comments","events_url":"https://api.github.com/repos/micropython/micropython/issues/1517/events","html_url":"https://github.com/micropython/micropython/pull/1517","id":111998510,"number":1517,"title":"extmod/modlwip: lwIP module for micropython","user":{"login":"galenhz","id":1783379,"avatar_url":"https://avatars.githubusercontent.com/u/1783379?v=3","gravatar_id":"","url":"https://api.github.com/users/galenhz","html_url":"https://github.com/galenhz","followers_url":"https://api.github.com/users/galenhz/followers","following_url":"https://api.github.com/users/galenhz/following{/other_user}","gists_url":"https://api.github.com/users/galenhz/gists{/gist_id}","starred_url":"https://api.github.com/users/galenhz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/galenhz/subscriptions","organizations_url":"https://api.github.com/users/galenhz/orgs","repos_url":"https://api.github.com/users/galenhz/repos","events_url":"https://api.github.com/users/galenhz/events{/privacy}","received_events_url":"https://api.github.com/users/galenhz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-10-18T03:21:20Z","updated_at":"2015-10-18T23:02:20Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/micropython/micropython/pulls/1517","html_url":"https://github.com/micropython/micropython/pull/1517","diff_url":"https://github.com/micropython/micropython/pull/1517.diff","patch_url":"https://github.com/micropython/micropython/pull/1517.patch"},"body":"General lwIP module for micropython. Not perfect; probably needs adjustments for other ports, memory utilization, and other minor issues, but it does its job for straightforward cases, and future improvements should be simple.\r\n\r\nTo use, you'll need to configure a SLIP connection on your friendly linux box. I do it as follows, your mileage may vary.\r\n\r\n    slattach -L -p slip -s 115200 /dev/ttyUSB0 &\r\n    ifconfig sl0 192.168.5.1 pointopoint 192.168.5.2 mtu 1500\r\n\r\nRun the following code on the pyboard to enable it:\r\n\r\n    import lwip\r\n    import pyb\r\n    lwip.reset()\r\n    tim = pyb.Timer(7)\r\n    tim.init(freq=20)\r\n    tim.callback(lambda t:lwip.callback())\r\n\r\n    u = pyb.UART(2, 115200, read_buf_len=3100)\r\n    sl = lwip.slip(2, \"192.168.5.2\", \"192.168.5.1\")\r\n\r\nThis will get a SLIP connection going on serial port 2, with the board configured as 192.168.5.2 and the linux host as 192.168.5.1.\r\n\r\nThe lwip.socket module works more or less like you'd expect.\r\n\r\n    sock = lwip.socket(lwip.AF_INET, lwip.SOCK_STREAM)\r\n    sock.connect((\"192.168.5.1\", 22))\r\n    print(sock.recv(1024))\r\n    sock.close()\r\n\r\nThat code will print the protocol version string from your local ssh server.\r\n"},"comment":{"url":"https://api.github.com/repos/micropython/micropython/issues/comments/149060058","html_url":"https://github.com/micropython/micropython/pull/1517#issuecomment-149060058","issue_url":"https://api.github.com/repos/micropython/micropython/issues/1517","id":149060058,"user":{"login":"dpgeorge","id":6187689,"avatar_url":"https://avatars.githubusercontent.com/u/6187689?v=3","gravatar_id":"","url":"https://api.github.com/users/dpgeorge","html_url":"https://github.com/dpgeorge","followers_url":"https://api.github.com/users/dpgeorge/followers","following_url":"https://api.github.com/users/dpgeorge/following{/other_user}","gists_url":"https://api.github.com/users/dpgeorge/gists{/gist_id}","starred_url":"https://api.github.com/users/dpgeorge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpgeorge/subscriptions","organizations_url":"https://api.github.com/users/dpgeorge/orgs","repos_url":"https://api.github.com/users/dpgeorge/repos","events_url":"https://api.github.com/users/dpgeorge/events{/privacy}","received_events_url":"https://api.github.com/users/dpgeorge/received_events","type":"User","site_admin":false},"created_at":"2015-10-18T23:02:20Z","updated_at":"2015-10-18T23:02:20Z","body":"> Hmm, right, need to put it there, even though it's not too beautiful.\r\n\r\nYeah, root pointers get ugly quickly, especially since sometimes you need to expose the type of the data, which can lead to more headers being included.\r\n\r\n> why stmhal reserved root pointer space for each of possible device object\r\n\r\nMain reason is because global variables are needed to implement IRQs.  Since the global variables are uPy objects, they must go in the root pointer space.\r\n\r\nBut it also serves a second purpose: to allow persistent peripheral objects, so \"constructing\" a UART the second time just reuses the existing instance (which makes sense because there is only 1 underlying physical peripheral for a given UART id)."}}