Comments (6)
Rong, I have observed similar behaviour and I have changed the driver a bit to take better consideration of the cdc acm line state. I am hoping to include this fix with my next cc2530-related pull request. When this happens, I'll appreciate it if you can take some time to test a little and give feedback.
Quick question, what OS is that behaviour on? You said putty so is this win or linux? I would also like to know if it's native or a VM. If it's on win, what driver are you using?
Thanks for mentioning this, at least now I know it's not just me.
On 14 Apr 2013, at 15:20, RONG Hongqian [email protected] wrote:
In my code some data is sent via USB to host periodically. If I plug the CC2531 device without running Putty to receive data, then after a while, open Putty, no data can be received. I made a simple patch but if someone have a way to make the device be able to recover from the overflow that will be better.
I guess some buffer overflows, and there are no proper code to recover from it. My solution now is to add these code:
if(!(usb_cdc_acm_get_line_state() & 0x01)){
leds_toggle(LEDS_RED);
return;
}to function usb_serial_writeb function in usb-serial.c .
So not single byte can be written to usb_tx_data[] buffer if DTR in line state word is not set.
I think this can possibly prevent some buffer from overflow if no application is reading from the USB. This patch is tested and it works, and host computer is using Putty or cat on Ubuntu 12.04.
But if someone have a way to make the device be able to recover from the overflow that will be better.
—
Reply to this email directly or view it on GitHub.
from contiki.
@g-oikonomou I have observed this behaviour on native Ubuntu 12.04, and also Ubuntu 12.04 in VM, when using Putty or cat /dev/ttyACM0 . With my very simple patch this behaviour disappears, tested using the Ubuntu in VM. I will test it later on the native Ubuntu.
from contiki.
Can you try this patch and let me know whether it improves the situation? Cheers
$ git show HEAD
commit e4a3cb3db13dff253258f7f2188777777a16e851
Author: George Oikonomou <[email protected]>
Date: Sat Mar 23 18:51:36 2013 +0000
Receive CDC ACM events and act accordingly
diff --git a/platform/cc2530dk/dev/usb-serial.c b/platform/cc2530dk/dev/usb-serial.c
index 4f766ab..a0cfea1 100644
--- a/platform/cc2530dk/dev/usb-serial.c
+++ b/platform/cc2530dk/dev/usb-serial.c
@@ -170,6 +170,16 @@ do_work(void)
enabled = 0;
}
+ events = usb_cdc_acm_get_events();
+ if(events & USB_CDC_ACM_LINE_STATE) {
+ uint8_t line_state = usb_cdc_acm_get_line_state();
+ if(line_state == (USB_CDC_ACM_DTE | USB_CDC_ACM_RTS)) {
+ enabled = 1;
+ } else {
+ enabled = 0;
+ }
+ }
+
if(!enabled) {
return;
}
@@ -254,6 +264,7 @@ PROCESS_THREAD(usb_serial_process, ev, data)
usb_setup();
usb_cdc_acm_setup();
usb_set_global_event_process(&usb_serial_process);
+ usb_cdc_acm_set_event_process(&usb_serial_process);
usb_set_ep_event_process(EPIN, &usb_serial_process);
usb_set_ep_event_process(EPOUT, &usb_serial_process);
from contiki.
Your patch works. I tested cat and putty on Ubuntu 12.04 in VM, and on native Ubuntu 12.04. The behaviour disappears in the tests. Cheers!
My suggestion is to change the
if(line_state == (USB_CDC_ACM_DTE | USB_CDC_ACM_RTS))
to
if(line_state & USB_CDC_ACM_DTE )
In Universal Serial Bus Class Definitions for Communication Devices v1.1 (available http://www.usb.org/developers/devclass_docs/usbcdc11.pdf), Page 58( Page69 in pdf), D15..D2 in control signal bitmap are reserved. Also, D1 (USB_CDC_ACM_RTS) is ignored if device is full duplex.
from contiki.
Your patch works. I tested cat and putty on Ubuntu 12.04 in VM, and on native Ubuntu 12.04. The behaviour disappears in the tests. Cheers!
Great, thanks for testing
My suggestion is to change theif(line_state == (USB_CDC_ACM_DTE | USB_CDC_ACM_RTS))
toif(line_state & USB_CDC_ACM_DTE )
That's a valid point, I didn't look at the spec when I wrote this, I was just going by what the host was sending me. Thanks for pointing this out.
from contiki.
Fixed with #199
from contiki.
Related Issues (20)
- cooja simulate
- Contiki TDMA
- COOJA / Clustering /RPL
- MSP 430 GCC problem HOT 1
- Tunslip6 error
- Kindly provide the method of enabling promiscuous mode in Cooja.
- cc2538-cc2592-dk flashing issue HOT 3
- msp-430 bsl linux file error
- Mqtt Implementation in Contiki HOT 1
- rpl-border-router can't use tsch ?
- How to display information in collect view using exemple/udp-ipv6/udp_client? HOT 1
- resolution HOT 2
- Assessment of the difficulty in porting CPU architecture for contiki
- Collectview Application died HOT 5
- STORE FILE IN CC2538 MICROCONTROLLER
- Assessment of the difficulty in porting CPU architecture for contiki
- Issues in the speed of mote simulation HOT 1
- Cooja GUI visual issue HOT 1
- Are there any resources or documentation that provide power consumption characteristics of Cooja motes, similar to real hardware. HOT 2
- How to flash contiki-ng into Launchpad cc1312R1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from contiki.