yh Tang
/
NuMaker-mbed-AWS-IoT-example
NuMaker connection with AWS IoT thru MQTT/HTTPS
pre-main/fetch_host_command.cpp@40:599eaf9deec3, 2020-12-01 (annotated)
- Committer:
- doudoutang
- Date:
- Tue Dec 01 03:36:42 2020 +0000
- Revision:
- 40:599eaf9deec3
- Parent:
- 29:e890b0fdce53
YES
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ccli8 |
29:e890b0fdce53 | 1 | /* |
ccli8 |
29:e890b0fdce53 | 2 | * Copyright (c) 2019 Nuvoton Technology Corporation |
ccli8 |
29:e890b0fdce53 | 3 | * |
ccli8 |
29:e890b0fdce53 | 4 | * SPDX-License-Identifier: Apache-2.0 |
ccli8 |
29:e890b0fdce53 | 5 | * |
ccli8 |
29:e890b0fdce53 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
ccli8 |
29:e890b0fdce53 | 7 | * you may not use this file except in compliance with the License. |
ccli8 |
29:e890b0fdce53 | 8 | * You may obtain a copy of the License at |
ccli8 |
29:e890b0fdce53 | 9 | * |
ccli8 |
29:e890b0fdce53 | 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
ccli8 |
29:e890b0fdce53 | 11 | * |
ccli8 |
29:e890b0fdce53 | 12 | * Unless required by applicable law or agreed to in writing, software |
ccli8 |
29:e890b0fdce53 | 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
ccli8 |
29:e890b0fdce53 | 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
ccli8 |
29:e890b0fdce53 | 15 | * See the License for the specific language governing permissions and |
ccli8 |
29:e890b0fdce53 | 16 | * limitations under the License. |
ccli8 |
29:e890b0fdce53 | 17 | */ |
ccli8 |
29:e890b0fdce53 | 18 | |
ccli8 |
29:e890b0fdce53 | 19 | #include "mbed.h" |
ccli8 |
29:e890b0fdce53 | 20 | |
ccli8 |
29:e890b0fdce53 | 21 | /* Fetch host command communicating via USB VCOM |
ccli8 |
29:e890b0fdce53 | 22 | * |
ccli8 |
29:e890b0fdce53 | 23 | * WARNING: For mass production, remove this file. |
ccli8 |
29:e890b0fdce53 | 24 | */ |
ccli8 |
29:e890b0fdce53 | 25 | |
ccli8 |
29:e890b0fdce53 | 26 | /* Check weak reference/definition at the link: |
ccli8 |
29:e890b0fdce53 | 27 | * http://www.keil.com/support/man/docs/ARMLINK/armlink_pge1362065917715.htm */ |
ccli8 |
29:e890b0fdce53 | 28 | |
ccli8 |
29:e890b0fdce53 | 29 | extern "C" { |
ccli8 |
29:e890b0fdce53 | 30 | MBED_USED int fetch_host_command(void); |
ccli8 |
29:e890b0fdce53 | 31 | } |
ccli8 |
29:e890b0fdce53 | 32 | |
ccli8 |
29:e890b0fdce53 | 33 | int fetch_host_command(void) |
ccli8 |
29:e890b0fdce53 | 34 | { |
ccli8 |
29:e890b0fdce53 | 35 | struct pollfd fds[1]; |
ccli8 |
29:e890b0fdce53 | 36 | |
ccli8 |
29:e890b0fdce53 | 37 | fds[0].fd = STDIN_FILENO; |
ccli8 |
29:e890b0fdce53 | 38 | fds[0].events = POLLIN; |
ccli8 |
29:e890b0fdce53 | 39 | int rc = poll(fds, sizeof(fds)/sizeof(fds[0]), 0); |
ccli8 |
29:e890b0fdce53 | 40 | if ((rc > 0) && (fds[0].revents & POLLIN)) { |
ccli8 |
29:e890b0fdce53 | 41 | return getchar(); |
ccli8 |
29:e890b0fdce53 | 42 | } else { |
ccli8 |
29:e890b0fdce53 | 43 | return -1; |
ccli8 |
29:e890b0fdce53 | 44 | } |
ccli8 |
29:e890b0fdce53 | 45 | } |