Forum

Please consider registering
guest

Log In Register

Register | Lost password?
Advanced Search

— Forum Scope —

  

— Match —

   

— Forum Options —

   

Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS
86duino stop working after closing Serial Monitor
2016 年 01 月 26 日
14:55:41
zerozaber
Moderator
Forum Posts: 52
Member Since:
2015 年 02 月 11 日
Offline

I have found out that if there is Serial.println in my code and it run, my system stop working after closing serial monitor for a while.
I think the cause is that 86duino won't send serial if serial monitor is not detected, and its send buffer is overloaded.

Please suggest me a solution so that I can stop printing if serial monitor is not detected, so that my system can run without problems.

Please note that I tried to ask if(Serial), but that will return true once the Serial begin.

2016 年 01 月 26 日
22:23:41
Android_Lin
Moderator
Forum Posts: 208
Member Since:
2014 年 04 月 01 日
Offline

Hi, zerozaber
I saw the source code for USB, and it has the protected behavior (start to send data when detecting serial monitor) in line 1804 in USBCore.cpp and line 96, 106 in CDC.cpp. And if want to stop printing if serial monitor is not detected, you can try to use "while(!Serial);"

Android_Lin

2016 年 01 月 27 日
14:08:21
zerozaber
Moderator
Forum Posts: 52
Member Since:
2015 年 02 月 11 日
Offline

The problem is that once serial monitor has been detected, Serial always return true even monitor has been closed.
I insert if(Serial) before every printing code, it still try to print.

2016 年 01 月 28 日
14:50:01
Android_Lin
Moderator
Forum Posts: 208
Member Since:
2014 年 04 月 01 日
Offline

I knew the condition you said, you met the problem because the 86Duino has to be compatible for Arduino Leonardo, and you will find that there is the problem under Windows, no problem under Linux (you also see this condition when using Arduino Leonardo).
Following is modification for 86Duino if want to solve the problem:

Open the USBCore.cpp, and modify line 723 from

if (usb->control_line_state == 0)

to

if ((usb->control_line_state & 0x01) == 0) // just see the first bit

everything is OK.

If you are interesting for this problem, refer the table3 in this page, and i find the "control line state" signal sent from PC is different. Under Linux, the value is 3 when serial monitor is detected, is 0 when serial monitor is not detected, it is no problem. But under Windows, the status value is 3 when serial monitor is detected, is 2 when serial monitor is not detected, it causes this problem.
I don't understand why the sent signal value are different under Windows and Linux, maybe the different USB drivers. Anyway, you can use the above method to solve.

Android_Lin

2016 年 01 月 28 日
18:11:09
zerozaber
Moderator
Forum Posts: 52
Member Since:
2015 年 02 月 11 日
Offline

Thanks a lot, I will try this soon.

Forum Timezone: Asia/Taipei

Most Users Ever Online: 66

Currently Online:
2 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Dinosaur: 27

leutenecker: 13

mrZagg: 10

lukeross: 8

tomka: 8

smeezekitty: 8

hippy: 8

Ekkehard: 8

UIdahoCIT: 8

blaxxun: 7

Member Stats:

Guest Posters: 0

Members: 1509

Moderators: 14

Admins: 5

Forum Stats:

Groups: 2

Forums: 10

Topics: 238

Posts: 1079

Newest Members: Carol Chou, Kai-Jung Chou, 1789, RegLiu, ameerawwad, asmanko, nekotwingo, ttronic, Davidpag, zaskia12

Moderators: Glaux: 70, uaa: 11, guigra: 17, asian55: 22, Android_Lin: 208, bcarroll: 12, cucubutter: 84, recycled-air: 12, stevemork: 16, zerozaber: 52, pongraczi: 20, George Andrews III: 56, poto: 11, garpastym: 20

Administrators: eveshih: 1, anthony: 31, viky6: 0, roboard: 135, hcl: 0