Skip to content
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

Q:How to modify arduino's serial driver? #6

Open
waythe opened this issue Feb 13, 2014 · 14 comments
Open

Q:How to modify arduino's serial driver? #6

waythe opened this issue Feb 13, 2014 · 14 comments

Comments

@waythe
Copy link

waythe commented Feb 13, 2014

Hi chunlinhan,
Thanks so much for the wifi lib, and I'm now tring to use it in my RM04.
I saw the most important tip: "MUST modify Arduino's serial driver to increase Rx buffer size or add hardware flow control support."
Sorry that I'm a newbie, could you please give some more introduction about how to modify the buffer size? and if not modified, can some simple program run? for example, send a get request to some http address.
BTW, I found a wifi module which may save time for connecting hardwares: http://item.taobao.com/item.htm?id=18633529918
http://item.taobao.com/item.htm?id=25481148978
Hope it helps to some guys.

@ghost
Copy link

ghost commented Feb 13, 2014

I don't modify Rx buffer size ,also can perform http request. But the recevied data is wrong.
The following code is to modify the WiFiWebClient example, I want visitor http://www.0756dy.com/test.html .

char server[] = "www.0756dy.com";    
  if (client.connect(server, 80)) {
    Serial.println("connected to server");

    // Make a HTTP request:
    client.println("GET /test.html HTTP/1.1\nHost: www.0756dy.com\nConnection: keep-alive\n");
    client.println();
  }

and received data is

Starting connection to server...
at+out_trans=0
at+out_trans=0
at+out_trans=0
+++���#32767
at+mode=?

at+remoteip=?

at+remotepro=?

at+remoteport=?

at+tcp_auto=?

at+CLport=?

connected to server
at+out_trans=0
GET http://www.0756dy.com/test.html HTTP/1.1
Host: www.0756dy.com
Connection: close


HTTP/1.1 400 Bad Request
Date: Thu, 13 Feb 2014 10:45:01 GMT
Server: Apache/2.2.3 (CentOS)
Content-Length: 305
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.2.3 (CentOS) Server at www.0756dy.com Port 80</address>
</body></html>
HTTP/1.1 400 Bad Request
Date: Thu, 13 Feb 2014 10:45:01 GMT
Server: Apache/2.2.3 (CentOS)
Content-Length: 305
Connection: close
Content-Type: text/html; charset=iso-8859-1

@waythe
Copy link
Author

waythe commented Feb 13, 2014

wow.. seems you're quite close to the success. problem may located at the request you've sent is not so correct. would you like to try set Connection:close? if keep-alive, I think it may need more http headers to judge if a request/response is finished.

@waythe
Copy link
Author

waythe commented Feb 13, 2014

Oh sorry, I tried in http://httptool.duapp.com/ , keep-alive can also get a correct response. Then that's not the problem. Now need a way to debug the content that sent by rm04. Reading source codes......

@chunlinhan
Copy link
Owner

Hi waythe,

Here are my modifications for HardwareSerial Lib (for my mega2560):
https://drive.google.com/folderview?id=0BwHknyUrLaIUbHdpdU5ITTJhTEk&usp=sharing

Only the size of Serial1 & Serial2 RX buffers is changed.

If your sketch consumes RX data quickly (like WiFiWebClient sample), it would work fine
without increasing Serial RX buffer. Or, your Serial RX buffer would keep full but RM04 still
transfers data and those data would lose.

@chunlinhan
Copy link
Owner

Hi commissar,

Did you use this patch?

bc2c91a

@waythe
Copy link
Author

waythe commented Feb 14, 2014

Thanks so much, I'll check it :).
By the way, when using scanwifi demo, I finally succeed to enter the AT
mode, but failed to get any SSID, the router is in the same room. what
would be the possible reason? and do I need to change the RM04 working as
client in web page?(I left it untouched because I think the AT cmd should
already done so)

and what's the difference of the 2 UART? I asked the seller of my RM04,
they say the 2nd UART is not enabled. But I can see configurations of the
2nd serial in web page. It confused me much.

2014-02-14 10:40 GMT+08:00 chunlinhan [email protected]:

Hi commissar,

Did you use this patch?

bc2c91ahttps://github.com/chunlinhan/WiFiRM04/commit/bc2c91a4d29854a6f2849fc5c602cef3c75dfe2a

Reply to this email directly or view it on GitHubhttps://github.com//issues/6#issuecomment-35050558
.

@chunlinhan
Copy link
Owner

Hi waythe,

for scanwidi demo, it might be due to Serial RX buffer size.
RM04 will return all SSID info at once, so if your Serial RX buffer is no big enough, then
my library would fail to parse SSID info.

second UART makes you have ability to connect to the other host at the same time if you already use UART1 to connect to one host.

It depends on your application. If your application just need to connect to one host
a time, second UART is not necessary.

My application needs to connect to 2 different hosts at the same time, so I need the second UART.

@ghost
Copy link

ghost commented Feb 15, 2014

hi,chunlinhan, Thanks for your reply.
I used the newest code.
Now ,I have found what is the problem.In switchToDataMode, the direct return return, it is can get correct data. While my device seems to determine whether for AT mode is always not return in time.

Although there is a problem, but the work in progress, sincerely thanks for your help.

@waythe
Copy link
Author

waythe commented Feb 16, 2014

Hi @chunlinhan , I tried the HardwareSerial and it works! thanks so much!
However, there's another problem, when I scaned wifis, at most 10 ssids are listed. while there should be more. Is that because buffer size is still not enough? how big I can set the buffer size at most?

@waythe waythe closed this as completed Feb 22, 2014
@waythe waythe reopened this Feb 22, 2014
@chunlinhan
Copy link
Owner

Hi waythe,

Please change the following definition in utility/wl_definitions.h :
#define WL_NETWORKS_LIST_MAXNUM 10

@sonicgadgets
Copy link

Hi I have similar problem although mine only shows 5 ssids and I have my max set to 20?
Any thoughts? Thanks in advance.

@waythe
Copy link
Author

waythe commented Mar 26, 2014

Thanks so much, I'll try so.

2014-03-05 12:34 GMT+08:00 chunlinhan [email protected]:

Hi waythe,

Please change the following definition in utility/wl_definitions.h :
#define WL_NETWORKS_LIST_MAXNUM 10

Reply to this email directly or view it on GitHubhttps://github.com//issues/6#issuecomment-36709378
.

@chasm907
Copy link

I have just started using this device on a UNO and when I try to use the library I get these errors:

utility\at_drv.cpp:2207: error: 'Serial1' was not declared in this scope
utility\at_drv.cpp:2207: error: 'Serial2' was not declared in this scope

Forgive me if this error has been discussed before. Would appreciate any help given.

@chunlinhan
Copy link
Owner

Hi chasm907,

Please check this: #3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants