BA
/
BaBoRo1
Embed:
(wiki syntax)
Show/hide line numbers
emac_test_broadcast.cpp
00001 /* 00002 * Copyright (c) 2017, ARM Limited, All Rights Reserved 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00006 * not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00013 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #include "mbed.h" 00019 #include "greentea-client/test_env.h" 00020 #include "unity.h" 00021 #include "utest.h" 00022 00023 #if MBED_CONF_APP_TEST_WIFI || MBED_CONF_APP_TEST_ETHERNET 00024 00025 #include "emac_tests.h" 00026 #include "emac_util.h" 00027 #include "emac_ctp.h" 00028 00029 using namespace utest::v1; 00030 00031 void test_emac_broadcast_cb(void) 00032 { 00033 emac_if_validate_outgoing_msg(); 00034 00035 static int counter = 0; 00036 00037 // Send three broadcast 00038 if (counter < 3) { 00039 emac_if_ctp_msg_build(100, eth_mac_broadcast_addr, emac_if_get_own_addr(), emac_if_get_own_addr()); 00040 counter++; 00041 } else if (counter < 6) { 00042 counter++; 00043 } else if (counter < 9) { 00044 emac_if_ctp_msg_build(50, eth_mac_broadcast_addr, emac_if_get_own_addr(), emac_if_get_own_addr()); 00045 counter++; 00046 } else if (counter < 12) { 00047 counter++; 00048 } else if (counter == 12) { 00049 emac_if_reset_outgoing_msg(); 00050 // ignore errors since just probing 00051 RESET_ERROR_FLAGS; 00052 #if MBED_CONF_APP_ECHO_SERVER 00053 printf("echo server started successfully\r\n\r\n"); 00054 counter = 255; 00055 #else 00056 worker_loop_end(); 00057 #endif 00058 } 00059 } 00060 00061 void test_emac_broadcast(void) 00062 { 00063 RESET_ERROR_FLAGS; 00064 SET_TRACE_LEVEL(TRACE_ETH_FRAMES | TRACE_SUCCESS | TRACE_FAILURE); 00065 00066 worker_loop_start(test_emac_broadcast_cb, 10 * SECOND_TO_MS); 00067 00068 PRINT_ERROR_FLAGS; 00069 TEST_ASSERT_FALSE(ERROR_FLAGS); 00070 RESET_OUTGOING_MSG_DATA; 00071 } 00072 00073 #endif
Generated on Tue Jul 12 2022 12:21:49 by
