Skip to content

Commit

Permalink
work around the run-anyways bug in ipywidgets jupyter-widgets/ipywidg…
Browse files Browse the repository at this point in the history
…ets#3915  by using Textarea()s exclusively
  • Loading branch information
BenGardiner committed May 8, 2024
1 parent 068e1eb commit 45a3dd3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 30 deletions.
14 changes: 9 additions & 5 deletions easy_isotp_send.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,17 @@
"outputs": [],
"source": [
"@interact_manual\n",
"def isotpsend(interface='slcan', channel='COM29', bitrate=[500000,250000,125000,1000000],\n",
" send_to_id='0x7e1', recv_from_id='0x7e9',\n",
" send_isotp_msg=widgets.Textarea('0102030405060708090a0b0c0d0e0f10111213',\n",
" layout=widgets.Layout(width='100%', height='60px'))):\n",
"def isotpsend(interface=widgets.Textarea('slcan'),\n",
" channel=widgets.Textarea('COM29'),\n",
" bitrate=[500000,250000,125000,1000000],\n",
" send_to_id=widgets.Textarea('0x7e1'),\n",
" recv_from_id=widgets.Textarea('0x7e9'),\n",
" send_isotp_msg=widgets.Textarea('0102030405060708090a0b0c0d0e0f10111213',\n",
" layout=widgets.Layout(width='100%', height='auto'))):\n",
" send_to_id = eval(send_to_id)\n",
" recv_from_id = eval(recv_from_id)\n",
" with CANSocket(interface=interface, channel=channel, bitrate=bitrate, can_filters=[{'can_id': recv_from_id, 'can_mask': 0x7FF}]) as csock:\n",
" with CANSocket(interface=interface, channel=channel, bitrate=bitrate,\n",
" can_filters=[{'can_id': recv_from_id, 'can_mask': 0x1FFFF}]) as csock:\n",
" with ISOTPSocket(csock, tx_id=send_to_id, rx_id=recv_from_id) as isock:\n",
" send_isotp_msg_bytes = binascii.unhexlify(send_isotp_msg)\n",
" print(\"send_isotp_msg:\")\n",
Expand Down
33 changes: 19 additions & 14 deletions easy_log.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
"id": "592ab2d0816777a2",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-11T13:23:25.514719Z",
"start_time": "2024-04-11T13:23:24.664482Z"
"end_time": "2024-05-08T14:38:39.390443Z",
"start_time": "2024-05-08T14:38:39.346147Z"
},
"jupyter": {
"source_hidden": true
Expand All @@ -74,7 +74,7 @@
"InteractiveShell.ast_node_interactivity = 'all'\n",
"\n",
"import ipywidgets as widgets\n",
"from ipywidgets import interact, interact_manual\n",
"from ipywidgets import interact, interact_manual, Textarea\n",
"\n",
"import pandas as pd\n",
"import qgrid\n",
Expand Down Expand Up @@ -105,8 +105,8 @@
"id": "53803edcc92a2dcc",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-11T13:23:26.604562Z",
"start_time": "2024-04-11T13:23:25.514719Z"
"end_time": "2024-05-08T14:38:39.451752Z",
"start_time": "2024-05-08T14:38:39.394444Z"
},
"jupyter": {
"source_hidden": true
Expand Down Expand Up @@ -165,8 +165,8 @@
"id": "eea12eb2-14ef-4eb4-a7b3-cf9445afa9f2",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-11T13:23:26.624210Z",
"start_time": "2024-04-11T13:23:26.604562Z"
"end_time": "2024-05-08T14:38:39.515752Z",
"start_time": "2024-05-08T14:38:39.455750Z"
},
"jupyter": {
"source_hidden": true
Expand All @@ -179,8 +179,10 @@
" f'({pkt.time:010.06f}) {interface}{channel} {pkt.identifier:03x}#{pkt.data.hex().ljust(18)} ; {str(pkt.data)}',\n",
" file=sys.stderr, flush=True)\n",
"\n",
"\n",
"@interact_manual\n",
"def canlog(interface='slcan', channel='COM29', bitrate=[500000,250000,125000,1000000], count=(0, 1000, 4)):\n",
"def canlog(interface=Textarea('slcan'), channel=Textarea('COM29'), bitrate=[500000, 250000, 125000, 1000000],\n",
" count=(0, 1000, 4)):\n",
" with CANSocket(interface=interface, channel=channel, bitrate=bitrate) as csock:\n",
" sniff(count=count, opened_socket=csock,\n",
" prn=lambda pkt: print_candump_stderr(pkt, interface, channel))"
Expand Down Expand Up @@ -212,8 +214,8 @@
"id": "ceae8bc9-af21-44ce-b110-bc133ea97810",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-11T13:23:26.654582Z",
"start_time": "2024-04-11T13:23:26.626391Z"
"end_time": "2024-05-08T14:38:39.577332Z",
"start_time": "2024-05-08T14:38:39.521750Z"
},
"jupyter": {
"source_hidden": true
Expand All @@ -222,7 +224,8 @@
"outputs": [],
"source": [
"@interact_manual\n",
"def canlog(interface='slcan', channel='COM29', bitrate=[500000,250000,125000,1000000], count=(0, 1000, 4)):\n",
"def canlog(interface=Textarea('slcan'), channel=Textarea('COM29'), bitrate=[500000, 250000, 125000, 1000000],\n",
" count=(0, 1000, 4)):\n",
" with CANSocket(interface=interface, channel=channel, bitrate=bitrate) as csock:\n",
" frames_list = sniff(count=count, opened_socket=csock)\n",
" df = pd.DataFrame({\n",
Expand Down Expand Up @@ -262,8 +265,8 @@
"id": "f146a41a-9047-4d32-9b5e-487b6ffbab30",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-11T13:23:26.691370Z",
"start_time": "2024-04-11T13:23:26.654582Z"
"end_time": "2024-05-08T14:38:39.639156Z",
"start_time": "2024-05-08T14:38:39.585209Z"
},
"jupyter": {
"source_hidden": true
Expand All @@ -272,11 +275,13 @@
"outputs": [],
"source": [
"@interact_manual\n",
"def canlog(interface='slcan', channel='COM29', bitrate=[500000,250000,125000,1000000], count=(0, 1000, 4)):\n",
"def canlog(interface=Textarea('slcan'), channel=Textarea('COM29'), bitrate=[500 000, 250000, 125000, 1000000],\n",
" count=(0, 1000, 4)):\n",
" feeder = CLIFeeder()\n",
" wire = WiresharkSink()\n",
" feeder > wire\n",
" p = PipeEngine(feeder)\n",
"\n",
" def sniff_action(pkt, interface, channel):\n",
" feeder.send(pkt)\n",
" if wire.f is not None:\n",
Expand Down
24 changes: 13 additions & 11 deletions easy_send.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
"id": "592ab2d0816777a2",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-07T03:07:51.451075Z",
"start_time": "2024-04-07T03:07:50.417714Z"
"end_time": "2024-05-08T14:40:47.345379Z",
"start_time": "2024-05-08T14:40:45.783398Z"
},
"jupyter": {
"source_hidden": true
Expand All @@ -74,7 +74,7 @@
"InteractiveShell.ast_node_interactivity = 'all'\n",
"\n",
"import ipywidgets as widgets\n",
"from ipywidgets import interact, interact_manual\n",
"from ipywidgets import interact, interact_manual, Textarea\n",
"\n",
"import binascii\n",
"import pandas as pd\n",
Expand Down Expand Up @@ -106,8 +106,8 @@
"id": "53803edcc92a2dcc",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-07T03:07:53.161235Z",
"start_time": "2024-04-07T03:07:51.453073Z"
"end_time": "2024-05-08T14:40:49.222957Z",
"start_time": "2024-05-08T14:40:47.348380Z"
},
"jupyter": {
"source_hidden": true
Expand Down Expand Up @@ -167,8 +167,8 @@
"id": "eea12eb2-14ef-4eb4-a7b3-cf9445afa9f2",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-07T03:07:53.211245Z",
"start_time": "2024-04-07T03:07:53.163626Z"
"end_time": "2024-05-08T14:40:49.235967Z",
"start_time": "2024-05-08T14:40:49.222957Z"
},
"jupyter": {
"source_hidden": true
Expand All @@ -189,7 +189,8 @@
"\n",
"\n",
"@interact_manual\n",
"def canlog(interface='slcan', channel='COM29', bitrate=[500000,250000,125000,1000000], count=(0, 1000, 4),\n",
"def canlog(interface=Textarea('slcan'), channel=Textarea('COM29'), bitrate=[500000, 250000, 125000, 1000000], ,\n",
" count=(0, 1000, 4),\n",
" send_data_msgs=widgets.Textarea('777#0102030405060708, 777#090a0b0c0d0e0f10',\n",
" layout=widgets.Layout(width='100%', height='60px'))):\n",
" with CANSocket(interface=interface, channel=channel, bitrate=bitrate) as csock:\n",
Expand Down Expand Up @@ -225,8 +226,8 @@
"id": "129860ba-0f65-4040-9541-cc99ccc4b849",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-07T03:07:53.267407Z",
"start_time": "2024-04-07T03:07:53.216378Z"
"end_time": "2024-05-08T14:40:49.235967Z",
"start_time": "2024-05-08T14:40:49.235967Z"
},
"jupyter": {
"source_hidden": true
Expand All @@ -241,7 +242,8 @@
"\n",
"\n",
"@interact_manual\n",
"def canlog(interface='slcan', channel='COM29', bitrate=[500000,250000,125000,1000000], count=(0, 1000, 4),\n",
"def canlog(interface=Textarea('slcan'), channel=Textarea('COM29'), bitrate=[500000, 250000, 125000, 1000000],\n",
" count=(0, 1000, 4),\n",
" send_data_msgs=widgets.Textarea('777#0102030405060708, 777#090a0b0c0d0e0f10',\n",
" layout=widgets.Layout(width='100%', height='60px'))):\n",
" with CANSocket(interface=interface, channel=channel, bitrate=bitrate) as csock:\n",
Expand Down

0 comments on commit 45a3dd3

Please sign in to comment.