このページはEtoJ逐語翻訳フィルタによって翻訳生成されました。

翻訳前ページへ


A simple internet server in an Arduino... but not a web server- art5simpsrv OVERALL HOME     Other 構成要素 for programmers, not Arduino 明確な/細部
ARDUINO: 最高の,を越す Page    支店 "A": Arduino Course    支店 "B": Arduino "How To"s and 事業/計画(する)s
ArduServer / ArduSimpSrv: Arduinos do TCP/IP
Recommend to StumbleUpon

Arduino as server

With input and 生産(高)

地元で... or across the internet

This page is browser friendly, by the way. Make your browser's window いっそう少なく wide than your whole 審査する and you will find the narrower columns much easier to read. For more tips, see my 力/強力にする Browsing hints.

What does ArduSimpSrv do??

The ArduSimpSrv is a server.

You have just used a "server". When you fetched the page you are reading, your browser, a web (弁護士の)依頼人, (Firefox? Safari? Whatever: the (弁護士の)依頼人 ソフトウェア) connected to the server from which the HTML for what you are looking at can be gathered by any web (弁護士の)依頼人. It sent you the HTML, and whatever you're reading this on (the (弁護士の)依頼人 金物類/武器類) has made it 利用できる in a wet-ware (your 注目する,もくろむs) friendly form.

The ArduSimpSrv is a SIMPle SeRVer

I have, どこかよそで, shown you how to create a web server with an Arduino, my ArduServer. That has it's uses. It's プロの/賛成のs and 反対/詐欺s. The ArduSimpSrv is a simpler 装置, so it won't do things that an ArduServer will, but because the 総計費s of serving HTML have been eschewed, there's more space in the Arduino, so it can do more in other directions. The "price" for this? You won't be able 接近 an ArduSimpSrv with a web browser. (弁護士の)依頼人 machines will need to be running (弁護士の)依頼人 ソフトウェア written for the ArduSimpSrv. You can't even 接近 it with telnet. Sorry. That's the "bad news" The good news is that a 解放する/自由な simple (弁護士の)依頼人 program for interacting with a ArduSimpSrv is 利用できる, 恐れる not! More on that in a moment.

If you would like a 名簿(に載せる)/表(にあげる) of "live" ArduServers and ArduSimpSrvs to 接近 a ArduSimpSrv, that link's "for you!". Just remember that to 接近 an ArduSimpSrv, you need to fetch the (解放する/自由な) bespoke (弁護士の)依頼人 ソフトウェア! That link will take you to a page discussing my ArduServer and ArduSimpSrv デモs. You may have come to THIS page FROM THAT page. (The link opens in a new tab or window, so you can get 支援する here easily.) There's a link there for downloading the 解放する/自由な ArduSimpSrv (弁護士の)依頼人 ソフトウェア. (If you are just getting started with these things, the "plain vanilla" "Arduserver" is the way to go. You 接近 those with an ordinary browser.)


Let's walk for now... we'll run later

(If you want to try running before you walk, you can "skip to the answer", the ArduSimpSrv sourcecode. That will open in a tab or window, to make it 平易な to get 支援する to here.)

Wow! 装置s 明白な across the internet! (弁護士の)依頼人s talking to servers! All pretty grand!

Are you afraid it might be too grand for you, at the moment? Don't be! The hardest parts can all be 打ち勝つ with nothing more than one PC, an Arduino with an ethernet 保護物,者, and a LAN.

(An aside, for the 利益 of (弁護士の)依頼人 / server newbies: We won't be doing it here, you can even do (弁護士の)依頼人/ server work in a 選び出す/独身 computer. No one said that the (弁護士の)依頼人 ソフトウェア and the server ソフトウェア had to be in different computers, did they?)

We'll start by having your PC talk to your ArduSimpSrv through the wires of your LAN. Once that'd working, it isn't a lot more 成果/努力 to 許す "部外者s" in, to connect to your ArduSimpSrv to the world through your LAN's 関係 to the internet. (Your ArduSimpSrv "会談" to your LAN's router. Where the requests from the router to the ArduSimpSrv (機の)カム from and where the services from the server go once they've been sent to the router are questions of little 関心 to the ArduSimpSrv.

What will you need to create an ArduSimpSrv

A big PC will be 伴う/関わるd in programming the Arduino, but it will not be 伴う/関わるd in the serving of the web page. It can be unplugged, turned off, etc, once the Arduino has been programmed.

You'll need an "always on" internet 関係, e.g. "broadband" or DSL or ADSL. You don't need a "static IP 演説(する)/住所", if that's worrying you. (We'll come 支援する to that 問題/発行する). You'll need a router, but you almost certainly already have one, if you've met the first 必要物/必要条件, above. You'll need a way to connect your Arduino to your LAN, i.e. an Ethernet interface.

You'll need to be careful about how 不正に you 妥協 the 安全 of your system. You have to "open a door" to 許す (弁護士の)依頼人s in. Try to 避ける throwing open every door of your system.

Ethernet interface 半導体素子: Wiznet W5100? ENC28J60?
And credit where 予定...

I should について言及する that the ソフトウェア 現在のd here 要求するs a Wiznet W5100. The いっそう少なく expensive 保護物,者s using Microchip ENC28J60 interfaces can probably be programmed to do 正確に/まさに what the ソフトウェア here does. (If you do that, I'd love to 地位,任命する your code, or at least a link to it.)

(This page was started in 2011. Please see my "March 2015 ENC28J60 update" page before buying or using one of them! (That page will open in a new tab. Just の近くに it to come 支援する here.))

I happened to use an "Ethernet プロの/賛成の" from Sparkfun, 供給(する)d (very quickly!) in the UK by Hobbytronics.co.uk to create the ArduSimpSrv. Any Arduino with a W5100 based ethernet interface should do. It doesn't 事柄 if the ethernet interface is on the Arduino board, or on a separate PCB.

現実に, it would be more 正確な to say that PCSensor.com and Fungus, from the Arduino 会議, created ArduSimpSrv! The former gave me the idea of how simple things could be, and the latter wrote the code I 明示するd. But without proper documentation, any 事業/計画(する) is lost. I hope that I am 供給(する)ing that 決定的な 成分.

A 捨てる of Good News, to 元気づける you up: You won't need any third party libraries for this work. Third party libraries have their place, but it is always nice when there is no YAC (Yet Another 複雑化) isn't it?

What it can do... and what it can't...

You may feel that the ArduSimpSrv doesn't do much. If so, remember: it is 単に a demonstration of some basic 概念s. It 供給するs you will a 爆撃する which you may 拡大する to do many things.... whatever you want it to do! By all means get in touch, if you are wondering "could it do....?". (Please say you (機の)カム from "art5SimpSrv.htm")

The ArduSimpSrv watches for 後継の 命令(する)s. It can serve more than one (弁護士の)依頼人 "同時に"... although this 面 has not been as extensively 実験(する)d as I would wish. I am but a "one-注目する,もくろむd king", as far as TCP/IP is 関心d. I'm trying to help the "blind" out there. If some two-注目する,もくろむd king has comments, they would be enthusiastically considered. I am 特に curious about whether I should be calling the "c.stop" which is 現在/一般に remmed out, and curious about whether 多重の (弁護士の)依頼人s 接近ing the server 同時に is going to lead to 涙/ほころびs. (I do at least have a reasonable background in the 金物類/武器類 and ソフトウェア of Arduinos and clones.)

The final ArduSimpSrv, as 述べるd here, can do the に引き続いて.

It can 答える/応じる to "turn LED on"/ "turn LED off" 命令(する)s... the LED 存在 connected to the ArduSimpSrv. It can give (弁護士の)依頼人s the 現在の reading from its light sensor. It can tell a (弁護士の)依頼人 how many 後継の requests have been 過程d since it was last re-booted. It still "答える/応じるs" to the $BB$82 命令(する)... but that is a 捨てる left over from the 開発 path. The 返答 is meaningless... but 一貫した! (We start by making it 答える/応じる to that 命令(する), for 推論する/理由s you don't need to worry about!) (If I ever get this web page finished, I hope to 追加する a small "frill" which will 原因(となる) the ArduSimpSrv to 放出する a tiny "beep" each time someone 接近s it, just to 警報 me to the fact that someone is trying it.)

New features are やめる easily 追加するd to the Arduino code which runs the server.

It is not so 平易な to make the 関連した complementary changes in the (弁護士の)依頼人 ソフトウェア, but neither is it ロケット/急騰する science to 延長する the 爆撃する you are given.

Some 詳細(に述べる)s...

The に引き続いて will program an Arduino with Ethernet to be a server at 192.168.0.242, serving on port 5202. Those numbers appear... once... in the code below. Change them, if you need your ArduSimpSrv someplace else. (The 装置's MAC 演説(する)/住所 is also in the code, although you would be VERY unlucky to find that you need to change that... unless you are using 多重の derivatives of this デモ. (All of the 装置s on one LAN must have different MAC 演説(する)/住所s.)

STOP PRESS: It seems that maybe there's an element of bad advice in some of the pages this is connected to.

It may be a bad idea to use any of the に引き続いて at the same time as a W5100 based 保護物,者. I am working on a 類似の 名簿(に載せる)/表(にあげる) for ENC28J60 interfaces... it seems it might be the same as the 名簿(に載せる)/表(にあげる) below, minus D4, An0 and An1... but your work might 同様に be W5100 friendly, too, don't you think?

... and D13, but this last one only if you "care" that on the 保護物,者 it goes to an LED, and from there through a resistor to ground. (This 単に 平行のs the same thing on many Arduino and clone boards... BUT, to digress from the digression, BE AWARE that the ソフトウェア behind "体制/機構()" and "宙返り飛行()" pulse D13 high 簡潔に before 遂行する/発効させるing whatever you 明示するd in "体制/機構()".)

Of course, I unwittingly used some of those lines in my designs. The designs SEEM to work, but it would be a good idea to take what I've put on those lines and move them どこかよそで. I will 徐々に be 改訂するing my designs as follows....

In every 事例/患者, to 修正する the ソフトウェア is 平易な... but you will need to look carefully to see whether what is 現在/一般に online has been 修正するd or not.

To change the line used for, say, the phototransistor watching the LED in, say, ArduServer2, the line....

(弁護士の)依頼人.print("<br>Analog input 0 reads: <b>");
(弁護士の)依頼人.print(analogRead(0));

... must be changed to...

(弁護士の)依頼人.print("<br>Analog input 1 reads: <b>");
(弁護士の)依頼人.print(analogRead(1));

... and you are done! (You'll have to move one wire on your breadboard, too, if you had it wired for the 初めの design.)

(Digression: Is nothing every 平易な? In 99.0% of my code, such a change would 単に have been a 事柄 of changing something like the "const byte bLEDpin=8;" at the start of the program. But in this 事例/患者, to 避ける fighting with... not hard... getting the 誘発する to identify the channel, I took a shortcut and 明示するd the channel explicitly instead of a 全世界の variable. Sigh.

Sorry! I could have done without this, too! When will the 公式の/役人 Arduino 場所/位置 have proper documentation of the ethernet 保護物,者 and library?? I am working on getting all my pages 変えるd to the "new 基準"... in the 合間, you'll just have to stay 警報!

The code below only 答える/応じるs to the $BB$82 命令(する). It is just a first step in our 旅行. The more 有能な ArduSimpSrv code 現れるs later in this tutorial.

//
// TCP004: A simple server... not a web server... for Arduino
//    Basic 見解/翻訳/版. One 命令(する), one (static) 返答.
//    See TCP005 for 拡大するd, "useful" 見解/翻訳/版.
// The (弁護士の)依頼人 ソフトウェア for this is TCP002 (See below)

// Ver: 04 Oct 2011

//    要求するs 目的 (手先の)技術d (弁護士の)依頼人 ソフトウェア.
//    TCP002.exe in....
//    http://sheepdogguides.com/zips/TCP001.zip
//    ... is suitable.
//    If you know of, or have written, Linux
//    同等(の)s, please 接触する http://sheepdogguides.com/
//
// See http://sheepdogguides.com/arduino/art5simpsrv.htm
//    for a guide to TCP004
//
// This code is in the public domain.
//
// It 要求するs a W5100 based ethernet interface, although 変えるing
//    the ソフトウェア to run with a Microchip ENC28J60 should not be hard.

#含む <SPI.h>
#含む <Ethernet.h>

//The に引き続いて 決定する the MAC 演説(する)/住所 and IP 演説(する)/住所
//   that will be in the ethernet 保護物,者 on your Arduino.
//Both must be unique on your LAN

uint8_t mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xEE };
uint8_t ip[] = { 192,168,0,242 };

//The に引き続いて 決定するs what port the server will listen on.
int iSPort = 5202;

Server server(iSPort);


//TKB: 令状 up Ethernet プロの/賛成の 問題/発行するs: At Sparkfun page ANSWER the %v/3.3v? question, pointing out that Ethernet プロの/賛成の
   //述べるd as "Ethernet 保護物,者 on an Arduino プロの/賛成の" and that both 3v3 and 5v プロの/賛成のs sold!

   //Also discuss problem of BUB/Optiboot, and tell people to look at ModernDevice page, where things explained nicely for us!!

   //Also: BUB 3v3 // Ethernet プロの/賛成の Gnd.... BUB's 3v3 NOT CONNECTED in SOME 事例/患者s.

   //ARGHHH!

   //Ask about/ discuss c.stop.....

無効の 体制/機構() {

  // Initialize the W5100 ethernet 半導体素子
  Ethernet.begin(mac, ip);

  // Start the serial library (for debug 生産(高))
  // The serial 監視する is not 要求するd for the server's 操作/手術.
  Serial.begin(9600);

  // Start the TCP server
  Serial.print("開始 server...\n");
  server.begin();
}

無効の 宙返り飛行()
{
  (弁護士の)依頼人 c = server.利用できる();
  if (c.connected()) {
    Serial.print("後継の 関係!\n");
    // Read two bytes from (弁護士の)依頼人
    uint8_t b1 = c.read();
    uint8_t b2 = c.read();
    // Debugging: Show me what the (弁護士の)依頼人 sent
    Serial.print("The (弁護士の)依頼人 said 0x");
    Serial.print(b1,HEX);
    Serial.print(" 0x");
    Serial.print(b2,HEX);
    Serial.print("\n");
    // を取り引きする the 関係
    if ((b1 == 0xBB) and (b2==0x82)) {
      // N.B.. 最大限 size of 返答 is 68 bytes (enough for 32 sensors)
      uint8_t 返答[68];
      // Create a 返答
      uint8_t *r = 返答;
      *r++ = 0xBB;
      *r++ = 0x82;
      *r++ = 0x01;
      *r++ = 0x01;
      *r++ = 0xFF;
      *r++ = 0xFF;
      // Send it

      c.令状(返答,r-返答);
    };
    // の近くに the 関係... TKB: の近くに 関係 or stop server? Don't want latter!
    //TKB REMMED OUT, as CONNECTION REPEATEDLY CLOSED...
    //c.stop();
    //seems to work! (Didn't (適切に) with c.stop... server shut 負かす/撃墜する?
  };//end of 宙返り飛行()

}

That code will 答える/応じる to a simple request, and send a simple answer. We WILL be 拡大するing the repertoire into more useful things... but that part is 平易な... you can probably "飛行機で行く" with your own ideas, off of the 創立/基礎 the above 供給するd. The request and the 返答 were 関連した to a now 消滅した/死んだ 事業/計画(する) I was working on... don't try to 人物/姿/数字 out why you would make the particular request, nor what the particular 返答 is good for... apart from 存在 a simple example of a (弁護士の)依頼人 / server interaction!)

The request it 答える/応じるs to is the two byte sequence...

$BB $82

That "request" is sent from the (弁護士の)依頼人 to the server. It is やめる like when you send something to your printer. Your computer (the printer's "(弁護士の)依頼人") sends something. Because of this, the printer (the "server") does something. The analogy breaks 負かす/撃墜する here, as what the printer does isn't, in any simple sense, "seen" by the "(弁護士の)依頼人"... but if the analogy helped, good. If not... just move on!)

The 返答, the thing the server sends 支援する to the (弁護士の)依頼人 is...

$BB $82 $01 $01 $01 $FF $FF

I WILL 令状 much more about this... later!

No 約束s... but you may find 地雷 online at...

http://mon7nc.dyndns.org:5202

(That URL also hosts other things you may find 利益/興味ing. Use just "http://mon7nc.dyndns.org", with a browser, e.g. Firefox, to see my FarWatch remote 前提s/ 天候 監視するing system in 活動/戦闘. 取って代わる the :5202 with :81, still using just a browser, to see my ArduServer... web service with input and 生産(高) across the internet, with just a browser 十分な as (弁護士の)依頼人. (Doing away with the "bespoke" (弁護士の)依頼人 which ArduSimpSrv needs might seem like a good idea, but it 限界s the 可能性のある of the system. But if a mere ArduServer will 会合,会う your needs, it is an 選択.)

So much for the server. What about a (弁護士の)依頼人? I can give you a ArduSimpSrv (弁護士の)依頼人 for Windows, TCP006. (That's a .zip とじ込み/提出する with the finished .exe inside it. The .exe is not a "体制/機構" type program.) If anyone would like to create (弁護士の)依頼人s for the Linux and Mac people, I will be delighted to put links to them from here.

If you 病弱な to 令状 your own (弁護士の)依頼人, be it a better one for Windows, or for another operating system, you can download the zip with the sourcecode for my tutorial on programming TCP/IP with Delphi, in it you will find some 収集するd 使用/適用s. As in the 事例/患者 of TCP006, those are the finished .exe's, not "体制/機構" type programs. The one you need is TCP002.

If you have 始める,決める up your own ArduSimpSrv, at 192.168.0.242 (you can change the IP 演説(する)/住所) on your LAN, or if my デモ is up at mon7nc.dyndns.org, then download TCP006 or TCP002. Run it. Put 5202 in for "port", put 192.168.0.242 or mon7nc.dyndns.org in for "server", and click "Send" (or "Cmd BB: Static reply"). If the server is running, you should get "G:01 +031.93" 支援する. (That is what TCP002 and TCP006 "translate" the "$BB $82 $01 $01 $01 $FF $FF" it received into.)

TCP002 is a little 壊れやすい. Stop it and 再開する it if you want to change parameters. Make the changes before hitting "Send". TCP002 creates an .ini とじ込み/提出する someplace on your disk, by the way. In your Windows directory, I think. Sorry. I believe that it at least uses a sensible 指名する, "TCP002... something".

TCP006 is more sophisticated, but not open source.

New, 改善するd!

Once you have that working, new ideas will arise. Re-save TCP004 as TCP005, change the program's 指名する in the rems at the 最高の,を越す of the program. We are going to make TCP005 do some rather fancier things than TCP004 did. The new stuff is 比較して trivial, and doesn't give away any new secrets of doing (弁護士の)依頼人 / server work... but it turns the program into something more 利益/興味ing than TCP004!

(解任する that if it 控訴s you better, you can just download the finished ArduSimpSrv code, TCP005.)

The next bit, an 早期に use of an LED, can be skimmed over... but bits of the に引き続いて will be carried 今後 into the "final" TCP005.

When turning TCP004 into TCP005, the first thing I did was 追加する an LED (with a resistor) on 数字表示式の line 5. (I won't 約束 to keep it there... but where the LED is connected is defined by a 選び出す/独身 line in the program, "uint8_t bLEDpin=5;"... or some other number instead of 5. Don't change the "8" in "uint8"! (P.S.: Since 令状ing this tutorial, I've revisited it, to move the LED we are talking about, の中で other things. Mr. Murphy was watching... I moved the LED to 数字表示式の line line 8, so now there are two "8"'s in the 訂正する 見解/翻訳/版 of the bLED setting line, but I 信用 you to keep your 8's straight. "8" is a lucky number to many, many people, after all! <^_^>)

Before you connect your LED, you should know that you're going to want to have it 向こうずね on the light sensor which we will 追加する in a minute. I wired the LED from the 数字表示式の line to ground (through the usual resistor), as I find it いっそう少なく 混乱させるing to have setting line high ("on") turn on the LED. (The LED on line 13 of my Ethernet プロの/賛成の seemed to have some problem... it didn't "work" 権利 for some 推論する/理由. Anyway... it would have been hard to get the light sensor "looking" at it.)

You can get things going nicely by...

Create a 全世界の boolean called boLEDOn. Create two subroutines: LEDOn() and LEDOff(). They... not too surprising, I hope, turn the LED on and off.... and they make the 明言する/公表する of boLEDOn whatever it should be. In 体制/機構() configure the pin for 生産(高), and call the LEDOn() subroutine.

Just before....

c.令状(返答,r-返答);

... 追加する...

if (boLEDOn) {LEDOff();} else {LEDOn();};

Hey presto! Now anyone watching the actual ArduSimpSrv can see each time a $BB $82 命令(する) is 問題/発行するd.

(That little escapade was just a quick way to be sure the LED 金物類/武器類 is working 権利, and to check that the LEDOn() and LEDOff() 決まりきった仕事s were built 正確に. The changing of the LEDs 明言する/公表する each time a $BB $82 命令(する) comes in is not 含むd in the 見解/翻訳/版 of TCP005 shown below.)

Next, 追加する a light sensor on analog input 1. (I.e., the second one, the one after "AnalogIn0".) As with the LED, you can put the sensor on the analog port of your choice. The code below assumes it is on Analog1.

Now we need to...

This 文書, sheepdogguides.com/arduino/art5SimpSrv.htm, is the 最終的な documentation for the ArduSimpSrv (弁護士の)依頼人/server 議定書, by the way.

I've decided on the に引き続いて 支配するs for my 命令(する)s....

命令(する)s will consist of two bytes.

The second byte will be the inverse of the first. This will 供給する a 天然のまま "checksum"-like check that a 命令(する) is valid.... not that, for the moment, that the program is doing any clever error 扱うing or 報告(する)/憶測ing. It looks at what it got. If it is a valid 命令(する), it 過程s it. If not, it ignores it.

"命令(する)s" $00-$0F are reserved for the 内部の use of (弁護士の)依頼人 ソフトウェア, and should never be sent to the server

I'm 配合 my 命令(する)s as follows....

All 返答s, 含むing the 承認 of a "responseless" 命令(する), will begin with the first 命令(する) byte. (This is to make parsing of the replies easier... if you know what 命令(する) is 存在 replied to, it is easier to know what the 判型 of the reply せねばならない be!)

(I will "speak" in hex, throughout....)

The first nibble of the 命令(する)s in the 部類s a-d above will be 5-8, それぞれ. In other words, to take an example, the 命令(する) $58 can be 推定する/予想するd to be something that 要求するs no parameters, and returns nothing more than an 承認.

"Turn LED off" is a good example. To that, I am 割り当てるing the 命令(する) $50.

"Turn LED on" will be 割り当てるd to $51.

"Read Light Sensor" will be 割り当てるd to $71, because the sensor is on channel 1. (結局, it will probably make more sense to use an $8x 命令(する), and send the "which channel" datum as a parameter... but for now we will keep things simple.

(It doesn't, of course, have to be a light sensor connected to the analog input, but I will keep speaking of light sensors, to keep the example 固める/コンクリート.)

I said that the 命令(する)s would consist of two bytes. With the "checksum" second byte, our 命令(する)s are.... in 新規加入 to the 遺産/遺物 $BB $82, which is now rather redundant and pointless, we have...

We will 認める all $5x 命令(する)s with three bytes as follows: The first byte will 単に be the 命令(する) itself, "said" 支援する to the (弁護士の)依頼人. The second byte will be the 初めの 命令(する) byte AND'd with binary 01010101. The third byte will be the 初めの 命令(する) byte XOR'd with binary 01010101. This simple 計画/陰謀 will not be hard to program, and it will give us some 指示,表示する物, at the (弁護士の)依頼人, that the 命令(する) we sent was received by the server. (This may not be my greatest bit of design, but it will do to put 負かす/撃墜する a "marker" for something which may one day be 改善するd!) (Thus: $50 will be 定評のある with $50$00$05; $51 will be 定評のある with $51$00$04)

The "Read light sensor" 命令(する) will return...
the 命令(する), repeated 支援する ($71),
the 初めの 命令(する) byte AND'd with binary 01010101,
followed by two more bytes, giving the value seen on the analog input, MSB first.
That will be followed by the 排除的 OR of the two bytes, again a basic checksum.

So: A $71 命令(する), when Analog1 is seeing $1234 will return $71$51$12$34$26.

So! Code for all that!

... I am going show you さらに先に 負かす/撃墜する this page!!! (The online ArduSimpSrv runs the fancier code, which 答える/応じるs to all the 命令(する)s 述べるd here. The online デモ参加者/実演宣伝者 ArduSimpSrv has the 約束d LED and light sensor connected to it.

A little 転換: The ArduSimpSrv also makes a little "beep" each time it 過程s a (弁護士の)依頼人 request. All of the 関連した code is pretty straightforward. Search for lines with "Beep" in them. And now, 支援する to work...

Before I を取り引きする that code, I am going to 器具/実施する another 命令(する): $7F. When a $7F is 問題/発行するd, it will be sent with it's inverse ($80), and will 原因(となる) the ArduSimpSrv to return: The 命令(する) byte ($7F) AND'd with binary 01010101: $55, followed by a two byte number, MSB first, showing the number of times it has 過程d a pair of bytes from the (弁護士の)依頼人 since it was booted, followed by those two numbers XOR'd. Thus, if $1233 命令(する)s have been 過程d, and the ArduSimpSrv receives a $7F$80, (the checksum byte for $7F is $80), then the ArduSimpSrv will 答える/応じる with: $7F$55$12$34$26. (It 答える/応じるs with $1234, because it counts the 命令(する) just received, before answering.)

First we'll create a 全世界の variable for that, calling it iCommandsAccepted. We will initialize that to 無 in 体制/機構(). We will increment it by one just after the lines...

uint8_t b1 = c.read();
uint8_t b2 = c.read();

Even without 器具/実施するing the $7F 命令(する), we can see that is working, 簡単に by 追加するing....

Serial.print("   ");
Serial.print(iCommandsAccepted);

... just before the debugging line...

Serial.print("\n");

... and then watching iCommandsAccepted go 1, 2, 3, 4... by using the serial 監視する. As we know it is working, the next thing is to 器具/実施する $7F, so the (弁護士の)依頼人 can see how many 命令(する)s have been 過程d. This, however, will 要求する not only changes to the code in the ArduSimpSrv, but also in the (弁護士の)依頼人 ソフトウェア. So be it! But ArduSimpSrv's changes first...

You won't see any 捨てるs of the に引き続いて ugly kludge in the final TCP005... but just as an illustration of the things you can do...

While I was developing TCP005, and had got this far, I used the $BB $82 handler to see if I was going to be able to return iCommandsAccepted to the (弁護士の)依頼人. I just changed...

      *r++ = 0xBB;
      *r++ = 0x82;
      *r++ = 0x01;
      *r++ = 0x01;
      *r++ = 0xFF;
      *r++ = 0xFF;

... to....

      *r++ = 0xBB;
      *r++ = 0x82;
      *r++ = 1;
      *r++ = 01+(iCommandsAccepted >> 8);//1 + MSB of iCommandsAccepted
      *r++ = iCommandsAccepted & 0xFF;//LSB of iCommandsAccepted
      *r++ = 0xFF;

...for long enough to see if I was on the 権利 跡をつける, and then put the code 支援する, and settled 負かす/撃墜する to a "proper" $7F handler. That is a messy kludge, make 複雑にするd by さまざまな factors to do with what the (弁護士の)依頼人 ソフトウェア is doing with the two bytes we messed with, the fact that problems arise if either is 無, etc., etc.... but when you learn to eschew the 誘惑 of trying something quick and dirty, I will redouble my 成果/努力s in the same worthwhile direction.

The $7E 命令(する): I have created a $7E 命令(する)... but not 実験(する)d it yet! The 職業 of the $7E 命令(する) is to return a string to the (弁護士の)依頼人 to tell the (弁護士の)依頼人 which 見解/翻訳/版 of the ArduSimpSrv the (弁護士の)依頼人 is 取引,協定ing with.

The $7E 命令(する) will 原因(となる) the ArduSimpSrv to return: The 命令(する) byte ($7E) AND'd with binary 01010100: $54, followed by three bytes number, MSB first, showing the 見解/翻訳/版 of the ソフトウェア, as defined in the bVerMostSB, bVerMidSB and bVerLSB bytes, followed by the last two numbers XOR'd. Thus, if the 見解/翻訳/版 is $00$01$02, and the ArduSimpSrv receives a $7E$81, (the checksum byte for $7E is $81), then the ArduSimpSrv will 答える/応じる with: $7E$54$00$01$02$03.

Our first 適切に coded 多重の 返答 server

In TCP004, there is a section that looks like this....

    // を取り引きする the 関係
    if ((b1 == 0xBB) and (b2==0x82)) {
      // N.B.. 最大限 size of 返答 is 68 bytes (enough for 32 sensors)
      uint8_t 返答[68];
      // Create a 返答
      uint8_t *r = 返答;
      *r++ = 0xBB;
      *r++ = 0x82;
      *r++ = 0x01;
      *r++ = 0x01;
      *r++ = 0xFF;
      *r++ = 0xFF;

      // Send 返答
      c.令状(返答,r-返答);

We're going to create some subroutines which will 過程 the different 命令(する)s. They will be called "ProcessBB82", "Process7F80", etc. We'll come to those in a moment. For now, we'll 改訂する the above, making it more (疑いを)晴らす....

    // を取り引きする the 命令(する)
    if ((b1 == 0xBB) and (b2==0x82)) {ProcessBB82};
    if ((b1 == 0x7F) and (b2==0x80)) {Process7F80};

      // Send 返答
      c.令状(返答,r-返答);

... and no, of course that won't work until we've taken care of some other things.

First of all, the c.令状(返答,r-resonse) was inside the 封鎖する 過程d only if the 条件 of the "if" was met. To 避ける needing 多重の instances of c.令状(..., I have introduced a new 全世界の boolean variable, boValidCommand. Inside each 命令(する) 過程ing subroutine, it is 始める,決める true. It is used thus...

    // を取り引きする the 命令(する)..
    boValidCommand=誤った;//始める,決める true within 命令(する) 加工業者s
    if ((b1 == 0xBB) and (b2==0x82)) {ProcessBB82};
    if ((b1 == 0x7F) and (b2==0x80)) {Process7F80};

    // Then, if 命令(する) seen, send 返答...
      if (boValidCommand) c.令状(返答,r-返答);

Unfortunately, my しっかり掴む of pointers is imperfect, and I had to "mess with" the way the string of bytes 接近d by c.令状 was defined. Here's enough of the working code, at this 行う/開催する/段階, to show you how I got out of the corner I'd painted myself into....

(snip...)
uint8_t 返答[68];
// N.B. Size of 返答 限られた/立憲的な by what you put in 事前の line.
// Be careful not to 侵略(する)/超過(する) the 衝撃を和らげるもの.
uint8_t bRespLen;

boolean boValidCommand;

(snip...)

無効の ProcessBB82(){
      uint8_t *r = 返答;
      *r++ = 0xBB;
      *r++ = 0x82;
      *r++ = 0x01;
      *r++ = 0x01;
      *r++ = 0xFF;
      *r++ = 0xFF;
      bRespLen=6;
      boValidCommand=true;
}

無効の Process7F80(){

(類似の)

      boValidCommand=true;
}

(snip...)

無効の 宙返り飛行(){
  (弁護士の)依頼人 c = server.利用できる();
  if (c.connected()) {
    Serial.print("後継の 関係!\n");
    // Read two bytes from (弁護士の)依頼人
    uint8_t b1 = c.read();
    uint8_t b2 = c.read();
    ++iCommandsAccepted;

(snip debugging lines...)

// を取り引きする the 命令(する)...
    boValidCommand=誤った;//始める,決める true within a 命令(する) 加工業者, if one 設立する
    if ((b1 == 0xBB) and (b2==0x82)) ProcessBB82();
    if ((b1 == 0x7F) and (b2==0x80)) Process7F80();

    // Send 返答
    if (boValidCommand) c.令状(返答,bRespLen);

    };//End of if c.connected (then...) 封鎖する

(snip final lines)

From the above, you can see the essence of everything that is left to reach the goals we 始める,決める at the 手始め. The 詳細(に述べる)s can be 設立する in the に引き続いて code. TCP002 can interact with the 改善するd, multi-命令(する) serving ArduSimpSrv, but it will only send the rather dull $BB$82 命令(する), and receive the rather dull $BB$82$01$01$FF$FF, which TCP002 translates into "G:01 +031.93"... but it WILL "work" with TCP002 as (弁護士の)依頼人.

To see the other 命令(する)s served, you have to use TCP006. Be sure you have a 見解/翻訳/版 from after 6 October 2011. The 見解/翻訳/版 ID is the date in the window's 肩書を与える 妨げる/法廷,弁護士業. (Some 予選 見解/翻訳/版s were 解放(する)d, which did not have all the features 利用できる now.) You can turn the LED connected to online デモ参加者/実演宣伝者 ArduSimpSrv on and off. You can see readings from the phototransistor connected to one of its analog inputs. (You'll get about 00004 when the LED is off, something a little over 00100 when it is on.) You can see the number of times the server has 答える/応じるd to a request since it was last booted. It still can send the rather pointless "BB" 命令(する)... It sends a $BB$82 命令(する), which gives rise to a 直す/買収する,八百長をするd 返答 that is "translated" into "G:01 +031.93" if all is 井戸/弁護士席. The 命令(する) and the 返答 are 捨てるs of where this 事業/計画(する) began, and do not 代表する anything meaningful at the moment!)

You can tell the ソフトウェア to read the 装置 繰り返して. If you turn this on, please do not 始める,決める the read frequency to more than once a minute, if you want to leave it running for a while. In fact, probably best not to leave it running for 延長するd periods, unless you are really, really keen. For short 実験(する)s, feel 解放する/自由な to read at the 最大限 once per second... but remember that others out there may want to play, and if too many people are reading at once per second, you may "break" the ArduSimpSrv. It is easier to bring 負かす/撃墜する with a 否定 of service attack than, say, eBay.

There's lots of work to be done on TCP006 still, to make it 強健な and 使用者 friendly... but you can already see what is possible! I hope you like it... it took hours and hours to create! I'm sorry to say that the sourcecode for TCP006 will not be 解放(する)d. The basics behind it are explained here. The "frills" are my "貿易(する) secret", for a 商業の app I am working に向かって.

Your 全世界の Audience

If you have 現実に done all of the above, so far you have a ArduSimpSrv which can be 接近d with (弁護士の)依頼人 ソフトウェア running on any PC on your LAN.

To make your ArduSimpSrv "明白な" to the world, you "only" need do xxx the same things done to make either of my ArduServers 明白な to the world. 結局, I hope to 分裂(する) that (警察などへの)密告,告訴(状) off into its own page. For now I 恐れる I must ask you to read through the tutorial on ArduServer2, where the (警察などへの)密告,告訴(状) does reside. I わびる for making you dig through the ArduServer2 stuff to find the bits you need. There's not "a lot"... when you know how. You need a domain 指名する, i.e. something like my mon7nc.dyndns.org (although it can be simpler, if you like!). You need a way to keep the DNS appraised of the 現在の IP 演説(する)/住所 of your domain. You need to configure your firewall and anti-malware ソフトウェア to 許す requests from (弁護士の)依頼人s into your LAN. That's "all". <^_^>

I've done a separate guide to why you need, how to 始める,決める up dyndns service.




The 完全にする Sourcecode

The sourcecode for the finished ArduSimpSrv is hosted on its own page. You just copy and paste from that page to your Arduino compiler/ uploader.




I hope that was useful...

I hope that was useful. Let me know if there are areas which weren't adequately explained? Let me know what "Gotchas" got you?

(I also hope that not too many people read this page before the link to the 完全にする sourcecode was 挿入するd! Sorry!)




Search for other things...


Please 公式文書,認める that I have two other 場所/位置s, and that the に引き続いて search will not 含む them. They have their own search buttons.

My Sheepdog Guides 場所/位置.
My Arunet 場所/位置.

   Search this 場所/位置 or the web        力/強力にするd by FreeFind
 
  場所/位置 search Web search
場所/位置 地図/計画する    What's New    Search
The search engine 単に looks for the words you type, so....
*    (一定の)期間 them 適切に.
*    Don't bother with "How do I get rich?" That will 単に return pages with "how", "do", "I"....

You can also search this 場所/位置 without using forms.
広告 from page's editor: Yes.. I do enjoy 収集するing these things for you... hope they are helpful. However.. this doesn't 支払う/賃金 my 法案s!!! If you find this stuff useful, (and you run an MS-DOS or Windows PC) please visit my freeware and shareware page, download something, and 循環させる it for me? Links on your page to this page would also be 高く評価する/(相場などが)上がるd!
Click here to visit editor's freeware, shareware page.


Want a 場所/位置 hosted, or email? You can also help me if you 調印する up 経由で this link to 1&1's services. (I wouldn't recommend them unless I was happy after several years as one of their 顧客s, but yes, they do 支払う/賃金 me if you use this link! As do the Google advertisers, about whom I know nothing, of course.)



Valid HTML 4.01 Transitional Page 実験(する)d for 同意/服従 with INDUSTRY (not MS-only) 基準s, using the 解放する/自由な, 公然と accessible validator at validator.w3.org

CSS behind the page checked, at least once upon a time!, with http://jigsaw.w3.org/css-validator/
Why does this page 原因(となる) a script to run? Because of the Google パネル盤s, and the code for the search button. Also, I have some of my pages' traffic 監視するd for me by eXTReMe tracker. They 申し込む/申し出 a 解放する/自由な tracker. If you want to try one, check out their 場所/位置. Why do I について言及する the script? Be sure you know all you need to about spyware.


Editor's Main Homepage
How to email or 令状 this page's editor, Tom Boyd

....... P a g e . . . E n d s .....