-
Notifications
You must be signed in to change notification settings - Fork 26
Add USBCDC_ECM example #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
## USBCDC_ECM example | ||
|
||
The example sends an Ethernet frame that carries "Hello world" payload with a custom EtherType to the host PC. You can capture the frame by using a program called "Wireshark": | ||
|
||
1. Flash the board, and ensure the target's USB is plugged into the PC. | ||
2. Open Wireshark. | ||
3. Click **Capture > Options** to select the correct capture interface. | ||
4. Click **Capture > Start**. | ||
5. Click captured packet from source address 12:34:56:78:9a:bc to see the "Hello world" payload. | ||
|
||
**Note:** Because Windows doesn't provide native support for the USB CDC-ECM model, you must use third party drivers to use this class on Windows. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (c) 2019 ARM Limited. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Licensed under the Apache License, Version 2.0 (the License); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "mbed.h" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we dont include license headers to the code files? Like this one, we have this documented in our license guide. If anyone copies this, should also copy the copyright + license. PLease add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've checked some files, some have some don't . All should so please add it here and should be LGTM |
||
#include "USBCDC_ECM.h" | ||
|
||
/* Ethernet II frame */ | ||
typedef struct { | ||
uint8_t dst_mac[6]; | ||
uint8_t src_mac[6]; | ||
uint16_t eth_type; | ||
char payload[12]; | ||
} packet_t; | ||
|
||
static packet_t packet = { | ||
.dst_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, | ||
.src_mac = {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc}, | ||
.eth_type = 0xaaaa, /* unused EtherType */ | ||
.payload = "Hello world" | ||
}; | ||
|
||
USBCDC_ECM ecm; | ||
|
||
int main() | ||
{ | ||
while (true) { | ||
ecm.send((uint8_t *)&packet, sizeof(packet)); | ||
wait(1.0); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
https://github.com/ARMmbed/mbed-os/#0063e5de32fc575f061244c96ac60c41c07bd2e6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One the API documentation merges, I'll update this README to point to it in a new PR.