ENC28J60 Library V3.3 full source code

General discussion on mikroBasic.
Author
Message
mando
Posts: 23
Joined: 28 May 2008 05:48

#76 Post by mando » 15 Oct 2008 18:54

yo2lio wrote:
mando wrote:This means we can connect the PIC directly to internet? :o
You can connect NOW the PIC to the INTERNET !!!
:oops: oops!

I tried reaching the PIC through Internet, but the PIC can reach Internet?

I mean..
Internet --> PIC = Tried and worked fine
PIC --> Internet = Can this be done?

Can the PIC send information to a site.. let's say a forum? (assuming all the algorithm for posting is done)

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#77 Post by yo2lio » 15 Oct 2008 19:05

Now you can do this over UDP. (client and server)
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

Bytex
Posts: 459
Joined: 23 Jun 2008 00:58
Location: Palmanova (UD), Italy
Contact:

#78 Post by Bytex » 15 Oct 2008 19:12

You can do that:

PIC_SENDER ----> |internet zone| ---> PC or PIC_RECEIVER

using UDP_SEND and UDP_RECEIVE

Code: Select all

  Str2Ip("xxx.xxx.xxx.xxx",user_ip_addr) ' PIC_RECEIVER IP address
  eth_port = 10001
  dest_port = xxxxx ' PIC_RECEIVER port number
Max

Best regards,
Max

http://www.b-vu.com

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#79 Post by yo2lio » 17 Oct 2008 13:28

Hello ALL,

Good News (17 OCTOBER 2008) , implemented :

- New Firewall Rules and Policy( drop or reject ) for unwanted packets.
- TCP Client (TCP_Open_Connection, TCP_Send, TCP_Close_Connection)
- TELNET Client.
- SMTP Client.
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

Bytex
Posts: 459
Joined: 23 Jun 2008 00:58
Location: Palmanova (UD), Italy
Contact:

#80 Post by Bytex » 17 Oct 2008 14:47

:D WOW :D

Thanks Florin.
I'm waiting for the new library.

But, are you joking or not ?



Max

Best regards,
Max

http://www.b-vu.com

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#81 Post by yo2lio » 17 Oct 2008 14:56

I don't joking .... :?

I thinking now, about how to implement TCP/IP Stack, and make library smaller ....

Probably the next version will work only with MCU with more than 48Kb of Flash and 2 Kb of RAM ...
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

Bytex
Posts: 459
Joined: 23 Jun 2008 00:58
Location: Palmanova (UD), Italy
Contact:

#82 Post by Bytex » 17 Oct 2008 15:13

Hi Florin,

About 8 months ago I bought the card you see in the picture.
It implements the TCP/IP stack of Microchip AN833, using a
simple P18F452 @10MHz.

I know, the TCP/IP stack is written in ansi C.

Image

AN833
http://www.microchip.com/stellent/idcpl ... e=en011993

Best regards,
Max

Best regards,
Max

http://www.b-vu.com

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#83 Post by yo2lio » 17 Oct 2008 15:17

Well, is very complicated to rewrite Microchip C library in MikroPascal or MikroBasic ... I can't do this !
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

mando
Posts: 23
Joined: 28 May 2008 05:48

#84 Post by mando » 17 Oct 2008 15:43

yo2lio wrote:Hello ALL,

Good News (17 OCTOBER 2008) , implemented :

- New Firewall Rules and Policy( drop or reject ) for unwanted packets.
- TCP Client (TCP_Open_Connection, TCP_Send, TCP_Close_Connection)
- TELNET Client.
- SMTP Client.
when are you planning to release this version?

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#85 Post by yo2lio » 17 Oct 2008 16:06

Probably at the end of November .
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

Bytex
Posts: 459
Joined: 23 Jun 2008 00:58
Location: Palmanova (UD), Italy
Contact:

#86 Post by Bytex » 17 Oct 2008 23:58

Hi Florin,

I tried to merge NTP software with UDP_Send software to get atomic time from internet
and send the output time string to my PC, using UDP protocol.

As you can see this is the output.

1970-01-01 00:01:04
1970-01-01 00:01:07
1970-01-01 00:01:10
1970-01-01 00:01:13
1970-01-01 00:01:16
1970-01-01 00:01:19
1970-01-01 00:01:22
1970-01-01 00:01:25
1970-01-01 00:01:28

I tried to change the NTP server IP address also.


This is the partial code I used:

Code: Select all

Sub Procedure Eth_SetParameters   ' set your parameters here

  Str2Ip("192.168.0.110",eth_ip_addr)
  Str2Ip("192.168.0.2",eth_gateway)
  Str2Ip("85.120.220.254",eth_ntp_addr) '
  Str2Ip("255.255.255.0",eth_mask)
  Str2Mac("0004A3008080",eth_mac)
  Str2Ip("192.168.0.14",user_ip_addr)

  eth_port = 10001
  dest_port = 10001

end sub

Code: Select all

main:


    ADCON1 = ADCON1 or 0x07           ' turn off analog inputs
    ADCON1.3 = 0

    TRISD = %00000000
    PORTD = 0

    TRISB.0 = 1
    PORTB.0 = 0

    GreenLed = false
    Btn = false

    Init
    Spi_Init_Advanced(MASTER_OSC_DIV4, DATA_SAMPLE_MIDDLE, CLK_IDLE_LOW, LOW_2_HIGH)
    Eth_SetParameters
    Eth_Init_(PORTB, 3, PORTB, 5)'(ENC_Port_CS, CS, ENC_Port_Reset, Reset)
    Wait_For_Lan

    if NTP_Sync = false then Ntp_query end if
    counter1 = 0

    while true
        Eth_DoPacket ' process incoming packets
        if counter1 > 5000 then ' repeat at 5000 ms
            counter1 = 0
            if NTP_Sync = false then Ntp_query end if
            Get_Time
            Success = Send_UDP(user_ip_addr, dest_port,
                                eth_port,
                                Str_Len(TTime.Str),
                                TTime.Str)
        end if
    wend

end.
I don't know the problem is my modifications in software or maybe
my hardware/software firewall

Thank you in advance,
Max

Best regards,
Max

http://www.b-vu.com

Bytex
Posts: 459
Joined: 23 Jun 2008 00:58
Location: Palmanova (UD), Italy
Contact:

#87 Post by Bytex » 18 Oct 2008 01:01

Hi Florin,

SOLVED

The problem was my router nat/firewall configuration.


:D :D GREAT :D :D

Kind regards,
Max

Best regards,
Max

http://www.b-vu.com

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#88 Post by yo2lio » 18 Oct 2008 14:09

One remark :

Please put other NTP address instead of Str2Ip("85.120.220.254",eth_ntp_addr)

because this address can be no longer valid ......
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#89 Post by yo2lio » 18 Oct 2008 21:12

SMTP Client example.

Display Number of available Messages in your Mail Box.

This example use incoming Eth_V4_0 / ENC_V4_0 library.

Image

Code example (unfortunately in MikroPascal for now ....) :

Code: Select all

  if dest_port_T = 110 then
    begin
      i := 0;
      while i < 32 do
        begin
          getRequest[i] := Eth_GetByte;
          inc(i);
        end;
      txt31 := '+OK Hello there.';
      if Mem_Cmp(@getRequest, @txt31, Str_Len(txt31)) = 0 then
        begin
          len_tcp_resp := CopyRamStringToEthMem_CP('USER office@yahoo.com);
          Eth_PutByte($0D);
          Eth_PutByte($0A);
          result := len_tcp_resp + 2;
          exit;
        end;
      txt31 := '+OK Password required.';
      if Mem_Cmp(@getRequest, @txt31, Str_Len(txt31)) = 0 then
        begin
          len_tcp_resp := CopyRamStringToEthMem_CP('PASS 7654TRGarT');
          Eth_PutByte($0D);
          Eth_PutByte($0A);
          result := len_tcp_resp + 2;
          exit;
        end;
      txt31 := '+OK logged in.';
      if Mem_Cmp(@getRequest, @txt31, Str_Len(txt31)) = 0 then
        begin
          len_tcp_resp := CopyRamStringToEthMem_CP('STAT');
          Eth_PutByte($0D);
          Eth_PutByte($0A);
          result := len_tcp_resp + 2;
          exit;
        end;
      txt31 := '+OK Bye-bye.';
      if Mem_Cmp(@getRequest, @txt31, Str_Len(txt31)) = 0 then
        begin
          result := 0;
          exit;
        end;
      txt31 := '+OK ';
      if Mem_Cmp(@getRequest, @txt31, Str_Len(txt31)) = 0 then
        begin
          i := 4;
          while getRequest[i] <> ' ' do
            begin
              messages_nb[i-4] := getRequest[i];
              inc(i);
            end;
          messages_nb[i-4] := 0;
          len_tcp_resp := CopyRamStringToEthMem_CP('QUIT');
          Eth_PutByte($0D);
          Eth_PutByte($0A);
          result := len_tcp_resp + 2;
          exit;
        end;
      exit;
    end;
main routine :

Code: Select all

    begin
      Eth_DoPacket;
      if NTP_Sync = false then Ntp_query;
      if TickCounter2 > 999 then
        begin
          TickCounter2 := 0;
          Get_Time;
          RemoveFirstNChr(TTime.Str, 10);
          text_ := ' Time ';
          Str_Cat(text_, TTime.Str);
          LcdOut(2,1,text_);
        end;
      if count_mess > 600 then
        begin

          messages_nb := '-1';

          if inc(TCP_opened_port) > 65000 then TCP_opened_port := 5000;
          
          TCP_Open_Port(TCP_opened_port);
          
          Open_TCP_Connection(user_ip_addr, dest_port, TCP_opened_port);
          
          count_mess := 0;
          while count_mess < 40 do
            begin
              Eth_DoPacket;
              if messages_nb[0] <> '-' then break;
            end;
            
          text_ := 'You have ';
          Str_Cat(text_, messages_nb);
          Str_Cat(text_, ' new messages');
          Str_Cat(text_, EOL);
          
          Send_UDP(user_ip_addr1, 10003, eth_port, Str_Len(text_), text_);
          
          TCP_Close_Port(TCP_opened_port);
          
          TickCounter2 := 0;
          if Str_Len(messages_nb) < 2 then Str_AppendPre(messages_nb, ' ');
          LcdOut(1,1,messages_nb);
        end;
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

Bytex
Posts: 459
Joined: 23 Jun 2008 00:58
Location: Palmanova (UD), Italy
Contact:

#90 Post by Bytex » 18 Oct 2008 22:59

:shock:
Simply great :D
Max

Best regards,
Max

http://www.b-vu.com

Post Reply

Return to “mikroBasic General”