Skip to content

Commit aa5afec

Browse files
committed
0.2.1 updates
1 parent 3c18e47 commit aa5afec

24 files changed

+902
-269
lines changed

.mbedignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
examples/autobahn/*
2-
examples/demo_client/*
3-
examples/transport/*
1+
doxygen/*
2+
examples/*
43

54

examples/mbed_ab_client/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
wic
2+
BUILD
3+
mbed-os
4+
.mbed
5+
upload_flash.jlink
6+
.gdbinit
7+
8+

examples/mbed_ab_client/.mbedignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/mbed_ab_client/example.cpp

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
*
2020
* */
2121

22-
#include "wic_client.hpp"
23-
#include "wic_nsapi.hpp"
22+
#include "wic_client.h"
23+
#include "wic_nsapi.h"
2424
#include "EthernetInterface.h"
2525
#include <cinttypes>
2626

@@ -56,20 +56,16 @@ int main()
5656
int n;
5757

5858
static EthernetInterface eth;
59-
static WIC::Client<sizeof(buffer),1012> client(eth);
59+
static WIC::Client<sizeof(buffer)> client(eth);
6060

6161
eth.connect();
6262

6363
retval = client.connect("ws://192.168.1.108:9001/getCaseCount?agent=mbed");
6464

6565
if(retval == NSAPI_ERROR_OK){
6666

67-
time_since();
68-
6967
retval = client.recv(encoding, fin, buffer, sizeof(buffer));
7068

71-
PUTS("recv() in %" PRIu32 "us", time_since());
72-
7369
if(retval < 0){
7470

7571
PUTS("failed to read number of test cases (%s)", WIC::nsapi_error_to_s(retval));
@@ -91,41 +87,27 @@ int main()
9187

9288
PUTS("BEGIN TC%d", tc);
9389

94-
time_since();
95-
9690
retval = client.connect(url);
9791

98-
PUTS("tc%d: open() in %" PRIu32 "us", tc, time_since());
99-
10092
if(retval == NSAPI_ERROR_OK){
10193

10294
for(;;){
10395

104-
time_since();
105-
10696
retval = client.recv(encoding, fin, buffer, sizeof(buffer));
10797

108-
PUTS("tc%d: recv() in %" PRIu32 "us", tc, time_since());
109-
11098
if(retval >= 0){
11199

112100
bytes = retval;
113101

114-
PUTS("tc%d: preparing to echo %d bytes of %s", tc, bytes, (encoding == WIC_ENCODING_UTF8) ? "text" : "binary");
115-
116-
#if 1
117102
time_since();
118103

119104
retval = client.send(buffer, bytes, encoding, fin);
120105

121-
PUTS("tc%d: send() in %" PRIu32 "us", tc, time_since());
122-
123106
if(retval != bytes){
124107

125108
PUTS("tc%d: breaking loop after send() returned %s", tc, WIC::nsapi_error_to_s(retval));
126109
break;
127110
}
128-
#endif
129111
}
130112
else{
131113

@@ -137,12 +119,10 @@ int main()
137119
time_since();
138120

139121
client.close();
140-
141-
PUTS("tc%d: close() in %" PRIu32 "us", tc, time_since());
142122
}
143123
else{
144124

145-
PUTS("tc%d: open() failed with retval %s", tc, WIC::nsapi_error_to_s(retval));
125+
PUTS("tc%d: connect() failed with retval %s", tc, WIC::nsapi_error_to_s(retval));
146126
}
147127

148128
PUTS("END TC%d", tc);
@@ -156,7 +136,7 @@ int main()
156136
}
157137
else{
158138

159-
PUTS("failed to connect");
139+
PUTS("connect() failed with retval %s", WIC::nsapi_error_to_s(retval));
160140
}
161141

162142
PUTS("all done");

examples/mbed_ab_client/makefile

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# This makefile is used for development
2+
#
3+
4+
DIR_PROJECT_ROOT := $(shell cd ../..;pwd)
5+
6+
# change this to point to your container
7+
DOCKER := docker run --mount type=bind,source=$(DIR_PROJECT_ROOT),destination=/mbed/wic --device=/dev/ttyACM0:/dev/ttyACM0 -ti --rm --user 1000:1000 -v $(shell pwd):/mbed:cached my-mbed-cli
8+
9+
# special MBED name for target
10+
DEVICE ?= NUCLEO_F429ZI
11+
#DEVICE ?= DISCO_L072CZ_LRWAN1
12+
13+
# special JLINK name for the target
14+
JLINK_DEVICE ?= STM32F429ZI
15+
16+
# need to slow it down?
17+
JLINK_SPEED ?= 4000
18+
19+
# location of toolchain in container
20+
PREFIX := $(DOCKER) /opt/gcc-arm/bin/arm-none-eabi
21+
22+
# location of the toolchain (can't seem to get GDB to work inside the container)
23+
LOCAL_TOOLCHAIN := /opt/arm/gcc-arm-none-eabi-9-2020-q2-update/bin
24+
25+
# toolchain commands
26+
GXX := $(PREFIX)-g++
27+
CC := $(PREFIX)-gcc
28+
AR := $(PREFIX)-ar
29+
OBJCOPY := $(PREFIX)-objcopy
30+
OBJDUMP := $(PREFIX)-objdump
31+
SIZE := $(PREFIX)-size
32+
GDB := $(LOCAL_TOOLCHAIN)/arm-none-eabi-gdb
33+
MBED := $(DOCKER) mbed
34+
GDB_SERVER := JLinkGDBServer
35+
JLINK := JLinkExe
36+
37+
DIR_BUILD := BUILD/$(DEVICE)/GCC_ARM-DEBUG
38+
39+
compile: $(DIR_BUILD)/mbed.elf
40+
41+
$(DIR_BUILD)/mbed.elf:
42+
$(MBED) compile -m $(DEVICE) -t GCC_ARM --profile debug
43+
44+
$(DIR_BUILD)/mbed.hex: $(DIR_BUILD)/mbed.elf
45+
$(OBJCOPY) -O ihex $< $@
46+
47+
flash: upload_flash.jlink $(DIR_BUILD)/mbed.hex
48+
$(JLINK) -device $(JLINK_DEVICE) -if swd -speed $(JLINK_SPEED) -CommanderScript $<
49+
50+
gdb: $(DIR_BUILD)/mbed.elf .gdbinit flash
51+
$(GDB) --command=.gdbinit -tui -q $<
52+
53+
gdb_server:
54+
$(GDB_SERVER) -if swd -device $(JLINK_DEVICE) -vd -speed $(JLINK_SPEED) -endian little
55+
56+
size: $(DIR_BUILD)/mbed.elf
57+
$(SIZE) $<
58+
59+
upload_flash.jlink:
60+
@ rm -f $@
61+
@ touch $@
62+
@ echo r >> $@
63+
@ echo h >> $@
64+
@ echo loadfile $(DIR_BUILD)/mbed.hex >> $@
65+
@ echo r >> $@
66+
@ echo g >> $@
67+
@ echo q >> $@
68+
69+
.gdbinit:
70+
@ rm -f $@
71+
@ touch $@
72+
@ echo target remote localhost:2331 >> $@
73+
@ echo dir $(DIR_PROJECT_ROOT)/src >> $@
74+
@ echo dir $(DIR_PROJECT_ROOT)/include >> $@
75+
@ echo dir $(DIR_PROJECT_ROOT)/port/mbed >> $@
76+
#@ echo monitor flash download = 1 >> $@
77+
#@ echo load >> $@
78+
@ echo monitor reset >> $@
79+
@ echo focus cmd >> $@
80+
81+
clean:
82+
rm .gdbinit upload_flash.jlink
83+
rm -rf $(DIR_BUILD)
84+
85+
.PHONY: clean gdb_server $(DIR_BUILD)/mbed.elf upload_flash.jlink .gdbinit config
86+
87+
config:
88+
$(MBED) compile --config -v

examples/mbed_ab_client/mbed_app.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}

examples/mbed_ab_client/readme.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
MBED Autobahn Client
22
====================
33

4-
This is for running against Autohahn. There are currently show
5-
stopping problems that show up in the high-thoughput tests.
4+
This is for running against Autohahn.
65

7-
Remove '*' from [.mbedignore](.mbedignore) to build.

examples/mbed_demo_client/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
wic
2+
BUILD
3+
mbed-os
4+
.mbed
5+
upload_flash.jlink
6+
.gdbinit
7+
8+

examples/mbed_demo_client/example.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/* Copyright (c) 2020 Cameron Harper
2-
*
2+
*
33
* Permission is hereby granted, free of charge, to any person obtaining a copy of
44
* this software and associated documentation files (the "Software"), to deal in
55
* the Software without restriction, including without limitation the rights to
66
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
77
* the Software, and to permit persons to whom the Software is furnished to do so,
88
* subject to the following conditions:
9-
*
9+
*
1010
* The above copyright notice and this permission notice shall be included in all
1111
* copies or substantial portions of the Software.
12-
*
12+
*
1313
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1414
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
1515
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
@@ -19,7 +19,7 @@
1919
*
2020
* */
2121

22-
#include "wic_client.hpp"
22+
#include "wic_client.h"
2323
#include "EthernetInterface.h"
2424

2525
int main()
@@ -30,7 +30,7 @@ int main()
3030
nsapi_size_or_error_t bytes;
3131

3232
static EthernetInterface eth;
33-
static WIC::Client<1000, 1012> client(eth);
33+
static WIC::Client<sizeof(buffer)> client(eth);
3434

3535
eth.connect();
3636

@@ -44,6 +44,6 @@ int main()
4444

4545
printf("got: %.*s\n", bytes, buffer);
4646
}
47-
48-
client.close();
47+
48+
client.close();
4949
}

examples/mbed_demo_client/makefile

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# This makefile is used for development
2+
#
3+
4+
DIR_PROJECT_ROOT := $(shell cd ../..;pwd)
5+
6+
# change this to point to your container
7+
DOCKER := docker run --mount type=bind,source=$(DIR_PROJECT_ROOT),destination=/mbed/wic --device=/dev/ttyACM0:/dev/ttyACM0 -ti --rm --user 1000:1000 -v $(shell pwd):/mbed:cached my-mbed-cli
8+
9+
# special MBED name for target
10+
DEVICE ?= NUCLEO_F429ZI
11+
#DEVICE ?= DISCO_L072CZ_LRWAN1
12+
13+
# special JLINK name for the target
14+
JLINK_DEVICE ?= STM32F429ZI
15+
16+
# need to slow it down?
17+
JLINK_SPEED ?= 4000
18+
19+
# location of toolchain in container
20+
PREFIX := $(DOCKER) /opt/gcc-arm/bin/arm-none-eabi
21+
22+
# location of the toolchain (can't seem to get GDB to work inside the container)
23+
LOCAL_TOOLCHAIN := /opt/arm/gcc-arm-none-eabi-9-2020-q2-update/bin
24+
25+
# toolchain commands
26+
GXX := $(PREFIX)-g++
27+
CC := $(PREFIX)-gcc
28+
AR := $(PREFIX)-ar
29+
OBJCOPY := $(PREFIX)-objcopy
30+
OBJDUMP := $(PREFIX)-objdump
31+
SIZE := $(PREFIX)-size
32+
GDB := $(LOCAL_TOOLCHAIN)/arm-none-eabi-gdb
33+
MBED := $(DOCKER) mbed
34+
GDB_SERVER := JLinkGDBServer
35+
JLINK := JLinkExe
36+
37+
DIR_BUILD := BUILD/$(DEVICE)/GCC_ARM-DEBUG
38+
39+
compile: $(DIR_BUILD)/mbed.elf
40+
41+
$(DIR_BUILD)/mbed.elf:
42+
$(MBED) compile -m $(DEVICE) -t GCC_ARM --profile debug
43+
44+
$(DIR_BUILD)/mbed.hex: $(DIR_BUILD)/mbed.elf
45+
$(OBJCOPY) -O ihex $< $@
46+
47+
flash: upload_flash.jlink $(DIR_BUILD)/mbed.hex
48+
$(JLINK) -device $(JLINK_DEVICE) -if swd -speed $(JLINK_SPEED) -CommanderScript $<
49+
50+
gdb: $(DIR_BUILD)/mbed.elf .gdbinit flash
51+
$(GDB) --command=.gdbinit -tui -q $<
52+
53+
gdb_server:
54+
$(GDB_SERVER) -if swd -device $(JLINK_DEVICE) -vd -speed $(JLINK_SPEED) -endian little
55+
56+
size: $(DIR_BUILD)/mbed.elf
57+
$(SIZE) $<
58+
59+
upload_flash.jlink:
60+
@ rm -f $@
61+
@ touch $@
62+
@ echo r >> $@
63+
@ echo h >> $@
64+
@ echo loadfile $(DIR_BUILD)/mbed.hex >> $@
65+
@ echo r >> $@
66+
@ echo g >> $@
67+
@ echo q >> $@
68+
69+
.gdbinit:
70+
@ rm -f $@
71+
@ touch $@
72+
@ echo target remote localhost:2331 >> $@
73+
@ echo dir $(DIR_PROJECT_ROOT)/src >> $@
74+
@ echo dir $(DIR_PROJECT_ROOT)/include >> $@
75+
@ echo dir $(DIR_PROJECT_ROOT)/port/mbed >> $@
76+
#@ echo monitor flash download = 1 >> $@
77+
#@ echo load >> $@
78+
@ echo monitor reset >> $@
79+
@ echo focus cmd >> $@
80+
81+
clean:
82+
rm .gdbinit upload_flash.jlink
83+
rm -rf $(DIR_BUILD)
84+
85+
.PHONY: clean gdb_server $(DIR_BUILD)/mbed.elf upload_flash.jlink .gdbinit config
86+
87+
config:
88+
$(MBED) compile --config -v
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}

examples/mbed_demo_client/readme.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

history.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
History
22
=======
33

4+
## 0.2.1
5+
6+
- default port is now set when no port is included in the URL
7+
- the MBED wrapper is now passing all non-perf tests
8+
49
## 0.2.0
510

611
Many enhancements to the original concept, the most significant being improved

mbed_lib.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name" : "wic",
3+
"config" : {
4+
"mss" : {
5+
6+
"help" : "WIC will never write more than this many bytes to socket send()",
7+
"value" : 536
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)