Tham khảo tài liệu 'hacking roomba - tod part 10', kỹ thuật - công nghệ, cơ khí - chế tạo máy phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 252 Part III More Complex Interfacing Listing 12-2 Continued else if cmd spinright roomba_spin_right vel else if cmd sensors sensors roomba_read_sensors c count sensors for i 1 i c i printf sensors i x n sensors i else if cmd drive vel _GET velocity rad _GET radius roomba_drive vel rad pre body html Figure 12-12 shows what the script looks like in the browser when run. Figure 12-12 Using the PHP Roomba program Chapter 12 Going Wireless with Wi-Fi 253 As you can see the Roomba functions seem very similar compared to the RoombaComm functions. The only strange statements are the pack statements like packf C 13 7 vhi vlo rhi rlo In PHP in order to send raw bytes with no string or numeric translation which is normally what you want you need to pack the bytes into a variable according to some packing rules. In the preceding statement C means to pack a series of unsigned bytes. The asterisk means an unknown number of bytes. In the preceding case you could use C5 since you re packing five bytes. When receiving data from Roomba you need to use a corresponding unpack method. If you expand to more fully control Roomba the first thing to do is to move the Roomba functions into their own file to build a Roomba PHP library called for example . You can then use this separate file with include at the top of your main PHP file. The HTML user interface is an example of using multiple Submit buttons for a single form. Each button sends a different value for cmd. You could have just as easily created multiple links and set the cmd query argument yourself. Putting It All Together Now that you have a working PHP page to control Roomba you can run it anywhere you can find a working LAMP system. This includes virtually all web hosting services on the Internet. In order to run from one of them you ll need to poke a hole in your firewall to allow computers outside your home network to connect. Most home routers have a .