Selamat datang di ForSa! Forum diskusi seputar sains, teknologi dan pendidikan Indonesia.

Welcome to Forum Sains Indonesia. Please login or sign up.

Maret 29, 2024, 06:28:17 AM

Login with username, password and session length

Topik Baru

Artikel Sains

Anggota
Stats
  • Total Tulisan: 139,653
  • Total Topik: 10,405
  • Online today: 134
  • Online ever: 1,582
  • (Desember 22, 2022, 06:39:12 AM)
Pengguna Online
Users: 0
Guests: 80
Total: 80

Aku Cinta ForSa

ForSa on FB ForSa on Twitter

mohon pencerahan para master sains

Dimulai oleh yulf1, Juli 09, 2011, 10:45:07 PM

« sebelumnya - berikutnya »

0 Anggota dan 1 Pengunjung sedang melihat topik ini.

yulf1

saya sedang tugas akhir tentang akuisisi data polusi udara berbasi web..
sensor yang digunakan TGS 2600 dan TGS 2201..tcp/ip modulnya pake NM7010A-lf.
saya sudah coba program dari IE pake bascom dan sudah berhasil. nh programnya

'-------------------------------------------------------------------------------
'                       NM7010A Network Module Test
'-------------------------------------------------------------------------------
$regfile = "m8535.dat"                                      ' specify the used micro
'$programmer = 1
$prog , &HA4 , &HD9,
$crystal = 8000000                                          ' used crystal frequency
$baud = 19200                                               ' use baud rate
$hwstack = 32                                               ' default use 32 for the hardware stack
$swstack = 10                                               ' default use 10 for the SW stack
$framesize = 40                                             ' default use 40 for the frame space

'used constants
Const Sock_stream = $01                                     ' Tcp
'Const Sock_dgram = $02                                      ' Udp
'Const Sock_ipl_raw = $03                                    ' Ip Layer Raw Sock
'Const Sock_macl_raw = $04                                   ' Mac Layer Raw Sock
'Const Sel_control = 0                                       ' Confirm Socket Status
'Const Sel_send = 1                                          ' Confirm Tx Free Buffer Size
Const Sel_recv = 2                                          ' Confirm Rx Data Size

'socket status
Const Sock_closed = $00                                     ' Status Of Connection Closed
'Const Sock_arp = $01                                        ' Status Of Arp
'Const Sock_listen = $02                                     ' Status Of Waiting For Tcp Connection Setup
'Const Sock_synsent = $03                                    ' Status Of Setting Up Tcp Connection
'Const Sock_synsent_ack = $04                                ' Status Of Setting Up Tcp Connection
'Const Sock_synrecv = $05                                    ' Status Of Setting Up Tcp Connection
Const Sock_established = $06                                ' Status Of Tcp Connection Established
Const Sock_close_wait = $07                                 ' Status Of Closing Tcp Connection
'Const Sock_last_ack = $08                                   ' Status Of Closing Tcp Connection
'Const Sock_fin_wait1 = $09                                  ' Status Of Closing Tcp Connection
'Const Sock_fin_wait2 = $0a                                  ' Status Of Closing Tcp Connection
'Const Sock_closing = $0b                                    ' Status Of Closing Tcp Connection
'Const Sock_time_wait = $0c                                  ' Status Of Closing Tcp Connection
'Const Sock_reset = $0d                                      ' Status Of Closing Tcp Connection
'Const Sock_init = $0e                                       ' Status Of Socket Initialization
'Const Sock_udp = $0f                                        ' Status Of Udp
'Const Sock_raw = $10                                        ' Status of IP RAW

Config Pind.4 = Output                                      ' Hardware reset NM7010A module
Set Portd.4
Reset Portd.4
Waitms 12
Set Portd.4

Enable Interrupts
' Change the MAC & IP address, SubMask, Gateway to appropriate to your network setting
' From computer connected to the network, type [pranala luar disembunyikan, sila masuk atau daftar.] at the Internet Explorer window
Config Tcpip = Int0 , Mac = 12.128.12.34.56.78 , Ip = 192.168.1.8 , Submask = 255.255.255.0 , Gateway = 192.168.1.1 , Localport = 1000 , Tx = $55 , Rx = $55 , Twi = &HCC , Clock = 300000

'dim used variables
Dim S As String * 200 , Shtml As String * 15 , Sheader As String * 30
Dim Tempw As Word
Dim I As Byte , P1 As Byte , P2 As Byte

Do
   Tempw = Socketstat(0 , 0)                                ' get status
   If Tempw = Sock_established Then
      Tempw = Socketstat(0 , Sel_recv)                      ' get received bytes
      If Tempw > 0 Then                                     ' if there is something received
         Do
            Tempw = Tcpread(0 , S)                          ' read a line
            If Left(s , 3) = "GET" Then
               Gosub Page
            End If
         Loop Until S = ""                                  ' wait until we get an empty line
         Tempw = Tcpwrite(0 , "HTTP/1.0 200 OK{013}{010}")  ' send ok
         Gosub Stuur                                        ' GET or HEAD or POST feedback so send it
         Closesocket 0                                      ' close the connection
      End If
   Elseif Tempw = Sock_close_wait Then
      Closesocket 0                                         ' we need to close
   Elseif Tempw = Sock_closed Then
      I = Getsocket(0 , Sock_stream , 80 , 0)               ' get a new socket
      Socketlisten 0                                        ' listen
   End If
Loop
End

'get html page out of data
Page:
   P1 = Instr(s , " ")                                      ' find first space
   P1 = P1 + 1                                              ' 4
   P2 = Instr(p1 , S , " ")                                 ' find second space
   P2 = P2 - P1
   Shtml = Mid(s , P1 , P2)                                 ' dont use too long page names
   Shtml = Lcase(shtml)                                     ' make lower case
Return

'send data
Stuur:
   Dim Wsize As Word , Ihitcounter As Integer
   Tempw = Tcpwrite(0 , "Content-Type: text/html{013}{010}")
   If Shtml = "/index.htm" Then                             ' data from eeprom
      S = "<html><head><title>Innovative Electronics</title></head><body><p><b>NM7010A test<br></b>by IE team<br><br>Hits : " + Str(ihitcounter) + "</p></body></html>"
      Incr Ihitcounter                                      ' increase hitcounter
      Wsize = Len(s)                                        ' size of body
      Sheader = "Content-Length: " + Str(wsize) + "{013}{010}"
      Tempw = Tcpwritestr(0 , Sheader , 255)                ' add additional CR and LF
      Tempw = Tcpwrite(0 , S , Wsize)                       ' send body
   End If
   Shtml = ""
Return


yang jadi masalah sekarang web yang dihasilkan masih berupa web statis,,
1. gimana supaya bisa jadi lebih dinamis
2. apakah bisa digabungkan dengan PHP atau sejenisnya
3. dan apakah bisa ditmbah aplikasi datasenya..??

mohon bantuannya,
terima kasih.