Using the Arduino Ethernet shield with AMICUS18 (Joint forum project?)


Closed Thread
Results 1 to 40 of 63

Hybrid View

  1. #1
    Join Date
    Sep 2012
    Posts
    5

    Default Re: Using the Arduino Ethernet shield with AMICUS18 (Joint forum project?)

    Hello Henrik!

    I would like to congratulate you for your very nice work here!
    You made me, buy a shield, modify the code and get it worked!
    Thank you that. I prefer that to a ready solution.

    What i did is i translated your code into Proton+ Compiler and made:
    a) a server, a simple web page with dynamic variables and
    b) a client, which loads values into cosm database (ex pachube).

    So, i would like to ask two questions:
    a) Do you use multisocket operation? Or only one socket? If yes, what is the basic concept? Opening all 4 sockets, set to listen and wait by looping pediocally to sockets wait for a "GET"request?
    b) There is a thought of opening a thread at Proton+ Compiler's forum with OF COURSE reference to you (your name and this thread's address) with some translation of your code into Proton. But i have to have your permission first.
    Take a look here:
    http://www.protonbasic.co.uk/showthr...797#post476797
    Last edited by VaGyver; - 6th September 2012 at 17:07.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,622

    Default Re: Using the Arduino Ethernet shield with AMICUS18 (Joint forum project?)

    Hi,
    Thank you, nice job on porting the code!

    I'm interested in how you implemented the dynamic variables. It's been quite some time since I worked on this code but last time I did work on it (back in January) I went of on a tangent starting to implement a subset of the Microchip File System for storing the webpage content in external flash instead of in the PIC. Geez, can't even remember where I left off....

    So, your two questions:
    a) The code should work for multiple sockets. I've not used it for multiple connections to a web-server but I've had one socket to DHCP, one socket DNS, one socket SNTP and one socket SMTP - at the "same" time.
    I don't think you should open all socket in listen mode at the same time though. If your device is acting as a server to serve up the web-page (or webpages) then you open a socket (say socket 0) and wait for a connection. When you get a connection on socket 0 you can open a second socket and wait for a connection on IT. That's probably how I'd try it as a start.

    b) Sure, go ahead! (Thank you for asking, I appreciate that!) If you build upon the code and post in the Proton forum perhaps there are ideas and implementations I can "convert back" into the PBP code and so on. That was kind of the idea of this thread from the start - to build a base or "framework" (popular word) for the W5100 which others could build "applications" around (web-server, emailer, twitter client etc). Obviously I would've preferred if you did it in PBP but you can't have it all ;-)

    If you do put something up please send me a link!

    Damn, now you resparked my interest in this... I even got a couple of WIZ820IO with the (now no longer brand new) W5200 chip that I was going to implement in the same code. Too many projects...

    /Henrik.

  3. #3
    Join Date
    Sep 2012
    Posts
    5

    Smile Re: Using the Arduino Ethernet shield with AMICUS18 (Joint forum project?)

    - About dynamic variaables:
    What i did is not effective, but works. I converted the variables to strings and then i just added to the rest string, meaning the Str Buffer.
    Fore example:
    StrN Buffer = Str$(Dec variable_to_publish)
    GoSub PutStringInTXBuffer

    - About multisocket:
    I am also searching this. The issue here is that i need to also pass dynamic variables as well. So, this means i must control all sockets simultanously (and my microchip chip also does other task too). Anyway, i will make some test on this and tell you the results.

    - Publish your (modified for Proton+ compiler) code:
    Of course i will do that (inform you). By the way, i intent, for start, only to publish a simple code that makes a web page with dynamic variables only (without DHCP). And i found out that these two compilers have very little differences.


    - I would like to ask a little help for a snippet. Why you are doing this in DHCP code, because i couldn't convert it with easy way?

    ' Get second Bit in DHCP_LeaseTime And copy it To first Bit of Buffer And so On.

    For DHCP_i = 0 To 30
    Buffer.0[DHCP_i] = DHCP_LeaseTime.0[DHCP_i + 1]
    Next

    Thank you in advance.


    Vangelis

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,622

    Default Re: Using the Arduino Ethernet shield with AMICUS18 (Joint forum project?)

    Hi,
    Thanks! Actually I was more aiming at what format you used to "place" a variable in the actual HTML and how you detect that when the program parses the HTML page to replace the "dynamic variable identifier" with the actual variable value. Does that make sense?

    Anyway, regarding the DHCP code:
    The lease time received from the DHCP server is a 32bit variable stored in the DHCP_LeaseTime array (4 bytes). The IP-adress lease must to be renewed before the lease time expires. What I do is simply divide the actual lease time in half, when that time (half of the actual lease time) expires the code triggers a renew of the lease.

    The code snippet you ask about performs that divide by 2 operation by shifting the value one step to the right. It uses the Buffer array as a temporary storage for moving Bit1 in LeaseTime to Bit0 in Buffer and so on. Finally it copies the shifted result back to DHCP_LeaseTime.

    The reason for doing it this way is that I wanted to avoid using LONGs (32bit variables) in PBP because it adds quite a bit of overhead. Using a LONG for the lease time and doing LeaseTime=LeaseTime/2 or LeaseTime=LeaseTime >> 1 would result in the same thing.

    Looking at the code now I could probably do something like this instead of using Buffer as a temporary storage
    Code:
    For DHCP_i = 0 To 30
      DHCP_LeaseTime.0[DHCP_i] = DHCP_LeaseTime.0[DHCP_i + 1]
    Next
    DHCP_LeaseTime.0[31] = 0
    Anyway, I hope that explains the what and why.

    /Henrik.

  5. #5
    Join Date
    Sep 2012
    Posts
    5

    Default Re: Using the Arduino Ethernet shield with AMICUS18 (Joint forum project?)

    I think that i understood it (the issue about dividing the time by 2).

    What i will do is that i will simply rotate each byte by 2 to the right individually. So it will be divided by two. The DHCP_LeaseTime[3] by 2, then the DHCP_LeaseTime[2] by 2, ........ lastly the DHCP_LeaseTime[0].
    I think it will have the same result.


    For the dynamic variables:
    I am not sure that i understood correctly what you are saying, but what i exactly do is placing the following html command. With this, the web page gets refreshed each 5 seconds.

    Str Buffer="<meta http-equiv=\"refresh\" content=\"5\">",13,10,0 'refresh every 5 seconds
    GoSub PutStringInTXBuffer


    You could select other time too, if you wish.
    So, the client (the person who sees your web page) will load again all the web page with the new variables (every 5 seconds). This is not quite effective since, sometimes, it makes a flashing on the page. But the data get refreshed correctly.
    There is also an other (more effective) way to do that (in order to avoid the flashing), with xml requests, but i am yet enough familiar with it.
    Last edited by VaGyver; - 7th September 2012 at 10:12.

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,622

    Default Re: Using the Arduino Ethernet shield with AMICUS18 (Joint forum project?)

    Hi,
    I'm afraid it's not quite that simple. Here's an example...

    24h = 86400 seconds

    Code:
    86400 in binary:
    00000000 00000001 01010001 10000000
    If you actually rotate each byte (ie the LSB gets moved to MSB) individually the result becomes:
    Code:
    00000000 10000000 10101000 01000000
    Which in decimal is: 8431680 seconds or 2352h
    If you instead of rotate simply shift each byte individually (or divide each byte by 2 individually) the result becomes:
    Code:
    00000000 00000000 00101000 01000000
    Which in decimal would be 10304 seconds or 2.9h
    As you can see neither of the above results is the expected 43200 seconds or 12h.

    You need to make sure that the LSB of each significant byte get moved into the MSB of the less significant byte so that result with the above numbers becomes:
    Code:
    00000000 00000000 10101000 11000000
    Which in decimal is: 43200 seconds or 12h
    /Henrik.

  7. #7
    Join Date
    Sep 2012
    Posts
    5

    Default Re: Using the Arduino Ethernet shield with AMICUS18 (Joint forum project?)

    Well, i solved this problem (i created a large variable and shift it -all together- one position to the right).
    I also verified it. It works.

    Now i am doing some testing with the W5100 as client to be connected to servers.

    I'll be in touch!

  8. #8
    Join Date
    Sep 2012
    Posts
    5

    Default Re: Using the Arduino Ethernet shield with AMICUS18 (Joint forum project?)

    Quote Originally Posted by HenrikOlsson View Post
    Hi,

    Damn, now you resparked my interest in this... I even got a couple of WIZ820IO with the (now no longer brand new) W5200 chip that I was going to implement in the same code. Too many projects...

    /Henrik.
    For your info:
    http://www.dacomwest.de/fileadmin/Da...0_20110923.pdf

  9. #9
    Join Date
    Mar 2014
    Posts
    5

    Default Re: Using the Arduino Ethernet shield with AMICUS18 (Joint forum project?)

    Hello,

    Henrik bravo !

    a wonderful project, a project I need my mail sender'm using 18F4620. I have W5100 or Amicus.


    henrik can help me?

  10. #10
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,622

    Default Re: Using the Arduino Ethernet shield with AMICUS18 (Joint forum project?)

    Hi,
    Sure, no problem, give me an hour and I'll write it up for you.
    Where do you want me to send it when it's finished?

    No, really. I'm trying to help as much as I can but it doesn't work like that. You give some and you get some.

    With that said, getting SMTP to work is not a simple task and it will not work with SSL or any other encryption. If you haven't done anything with the W5100 previosuly, like set it up to respond to a ping, serve a simple web page etc (the stuff that already IS detailed in this thread) then forget SMTP. At least untill you HAVE done the previous stuff and know a Little bit of how it works. I'm not saying that you don't, I'm just saying that if you DO then post your effort and I or someone else might be able to help you out.

    /Henrik.

  11. #11
    Join Date
    Mar 2014
    Posts
    5

    Default Re: Using the Arduino Ethernet shield with AMICUS18 (Joint forum project?)

    I agree absolutely with you the same ...

    I did, the web page, UDP, TCP, with ENC28J60. but the W5100. liked very much.

    I'm done with ping 5100.

    I'm done with protons + 18F4620 software. I've revised your ping code for the proton.

    I must take a little more now.

    I bought a new module.

    http://www.elektrovadi.com/w5100-ethernet-modul, PR-1389.html

    then I'll continue with this module.

    I wrote you about my progress from time to time. maybe I can come to the smtp portion.

    You have to believe that I'm the one who worked very hard

    ty for help.. If there is a flow diagram with smtp me if he could be good enough for me.

    bye


    Name:  foto?raf 1.jpg
Views: 2421
Size:  667.5 KB

  12. #12
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,622

    Default Re: Using the Arduino Ethernet shield with AMICUS18 (Joint forum project?)

    Hi,
    Ah, excellent work! Too bad you're using the wrong compiler. ;-)

    Everything you need to know is in the RFCs covering the SMTP protocol but they can be a bit "much" from time to time. I also, strongly suggest that you do some "manual" emailing using telnet to your intended server, that way you get a feel for the protocol and what it "looks like". Anyway, here's a list from my notes
    • Setup a free socket with IP adress and port (usually 25 or 2525) of remote SMTP server.
    • Open the socket and wait for it to initialize.
    • Issue the sockets connect command, ARP request resolves the remote MAC adress and populate the W5100 registers.
    • Wait for remote server to return a response 220. If it doesn't the remote server probably isn't a SMTP server.
    • Send EHLO adress.domain
    • Wait for remote server to return a response 250
    • Send AUTH LOGIN
    • Wait for server remote server to return a response 334
    • Send the username of the email account, BASE64 encoded
    • Wait for server remote server to return a response 334
    • Send account password, BASE64 encoded
    • Wait for remote server to return a response 235 - when received the connection is authenticated.
    • Send the Mail From: command
    • Wait for remote server to return a response 250
    • Send the Rcpt To: command
    • Wait for remote server to return a response 250
    • Send the DATA command
    • Wait for remote server to return a response 354
    • Send a <CR><LF>, a valid email header, the content of the email, followed by <CR><LF>.<CR><LF> (note the dot)
    • Wait for remote server to return a response 250
    • Send the QUIT command
    • Wait for remote server to return a response 221 (bye bye).
    • Close the connection.

    A complete email including the header might look like this, note the blank lines and the dot at the end.

    Date: Tue, 25 Mar 2014 19:18:00 +0200
    Message-Id: <1234>
    From: Your W5100
    To: Someone <[email protected]>
    Subject: Test

    Hello,
    This is a test.
    .

    If you don't want to use authenticated login the use the HELO command instead of EHLO.

    And again, note that the above will not work with email servers requiring SSL or other encryption.

    /Henrik.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts