ãããã¯ã¼ã¯æ¸©åº¦è¨
å®ã¯å é±ãH8ãã¤ã³ã³ã使ã£ã¦ãããã¯ã¼ã¯æ¸©åº¦è¨ãä½ãã¾ããã
ãã£ã¤ãå®è£
ã§ãããä¸å¿ããã¤ã³ã³ãã¼ãåä½ã§åä½ãã¾ãã
ï¼°ï¼£ä¸è¦ã§ã¹ã¿ã³ãã¢ãã³ã§åä½ããã¨ããããã¤ã³ã³ã®ç´ æµãªã¨ããã§ãã
ï¼ç§ããã®å®¤æ¸©ã測å®ãã¦ããµã¼ãã«UDPã§ãã¼ã¿ãéä¿¡ãã¾ãã
ãµã¼ãã§ã¯åä¿¡ããã°ã©ã ãèµ°ã£ã¦ãããåãåã£ããã¼ã¿ããã®ã³ã°ã
ç¾å¨ã®å®¤æ¸©ã¯ç¡æå³ã«ã±ã¼ã¿ã¤ãPCã®ãã©ã¦ã¶ãã確èªã§ããããã¾ãã
ã§ãï¼é±éã®éããã¼ã¿ã測å®ãã¦ããããã¾ããã
æ¥ä¸ã¯ï¼ï¼åº¦ãããã¾ã§ä¸ãããã§ãã
ä¸ã®å³ã¯å¸°å®
ãã¦ããã®å¹³åçãªå®¤æ¸©å¤åãã°ã©ãã«ã¾ã¨ãããã®ã§ãã
èªåã®è¡åï¼ä¸»ã«ã¨ã¢ã³ã³æä½ï¼ç¬ï¼ï¼ã¨ä¸å¿«ææ°ã®æ¨ç§»ãæã«åãããã«ãããã¾ããã
å人çã«ã¯æ¸©åº¦å¤åãè¦äºã«å¯¾æ°é¢æ°ã«ãªã£ã¦ããã®ã«æå¿ãã¾ããã
èªç¶æ³åã£ã¦ã¡ããã¨åãã¦ããã ãªãã¨åèªèã
æå¾ã«ãH8ã¨ãã®ã³ã°ç¨ãµã¼ãã®ããã°ã©ã ã³ã¼ããæãã¦ããã¾ãã
H8ã¯MES2ç¨ã®Cè¨èªããµã¼ãã¯C#ã§æ¸ãã¦FreeBSD7.0ã®monoä¸ã§åããã¦ãã¾ãã
å
容ã¯ã»ã¼åèãµã¤ãã®ãµã³ãã«ããã°ã©ã ã§ãããã¾ããã®ãã¤ã³ã³å®é¨å®¤ãããã¨ãDOBON.NETããããåèã«ããã¦é ãã¾ããã
ã©ãããããã¨ããããã¾ããã
ããã¾ããã®ãã¤ã³ã³å®é¨å®¤ã
http://wiki.livedoor.jp/yamamaya_com/d/A/D%a5%b3%a5%f3%a5%d0%a1%bc%a5%bf%a4%f2%bb%c8%a4%c3%a4%c6%a4%df%a4%eb
ãDOBON.NETã
http://dobon.net/vb/dotnet/file/writefile.html
MES2ç¨æ¸©åº¦æ¸¬å®ï¼UDPéä¿¡ããã°ã©ã
#include <h8/reg3067.h> #include <mes2.h> #include <string.h> #define VREF 5.0 #define NUM_SAMPLING 100 int main(int argc, char **argv) { volatile int w ; int a, b, i ; float v, t ; int log_fd ; int sock; //ã½ã±ãã int lcd;//LCD int tr,ts; char str[128]; struct sockaddr addr ; ///LCDã®åæå lcd = open("lcd0", 0); if(lcd == -1){ printf("LCD Initialize error...\r"); exit(0); } //ã½ã±ããä½æ sock = udp_socket() ; if(lcd == -1){ printf("Socket create error\r"); exit(0); } //ãµã¼ãã¢ãã¬ã¹è¨å®(é©å½ã«æ¸ãæãã¦ã) addr.sin_addr = IPADDR( 192,168, * , *** ); addr.sin_port = 2002 ; while(1){ fprintf(lcd, "wati...") ; printf("wait...^") ; /* ãµã³ããªã³ã°ï¼å¹³åå */ b = 0 ; for ( i = 0 ; i < NUM_SAMPLING ; i ++ ) { w = ADCSR ; ADCSR = 0x20 ; while ( ! ( ADCSR & 0x80 ) ) { } a = ADDRAH << 2 ; a |= ADDRAL >> 6 ; b += a ; sleep( 10 ) ; } /* èªã¿åãå¤ â é»å§ */ v = VREF / 1024 * ( (float)b / NUM_SAMPLING ) ; /* é»å§ â 温度 */ t = 218.5 - v / 0.008 ; tr = (int)t; ts = (int)( t * 10 ) % 10 ; fprintf(lcd, "%d.%01dï¾C\r", tr , ts ) ; printf("%d.%01dï¾C\r",tr,ts) ; sprintf(str,"%d.%01d", tr , ts) ; sendto( sock, str, strlen(str) , &addr ) ; } udp_free(sock); return 0; }
ãã®ã³ã°ç¨ãµã¼ãããã°ã©ã
using System; using System.Collections.Generic; using System.Text; namespace UDP_get { class Program { static void Main(string[] args) { //æåã³ã¼ããæå®ãã System.Text.Encoding enc = System.Text.Encoding.ASCII; //ãã¤ã³ããããã¼ã«ã«ãã¼ãçªå· int localPort = 2002; //ãã¼ã«ã«ãã¼ãçªå·localPortã«ãã¤ã³ããã System.Net.Sockets.UdpClient udp; udp = new System.Net.Sockets.UdpClient(localPort); //ãã¼ã¿ãåä¿¡ãã System.Net.IPEndPoint remoteEP = null; while (true) { byte[] rcvBytes = udp.Receive(ref remoteEP); string rcvMsg = enc.GetString(rcvBytes); Console.WriteLine("Recv:{0}", rcvMsg); Console.WriteLine("From:{0}/Port:{1}",remoteEP.Address, remoteEP.Port); //ãã°ãæ¸ãåºã string textFile = "log.txt"; //æ¸ãè¾¼ãæåå string str = rcvMsg + "\n"; //textFileã®æ«å°¾ã«strãæ¸ãå ãã System.IO.File.AppendAllText(textFile, str, enc); System.IO.File.WriteAllText("--path-to-logfile--", str, enc); } //UDPæ¥ç¶ãçµäº udp.Close(); Console.ReadLine(); } } }
ã¯ãã¸ã£ããå¯ããã