Shop OBEX P1 Docs P2 Docs Learn Events
Email from Parallax PINK internet module — Parallax Forums

Email from Parallax PINK internet module

Tracy AllenTracy Allen Posts: 6,662
edited 2006-11-29 17:54 in BASIC Stamp
Hi Ryan, or others,

I've scanned the documentation, and it is not clear to me how to get content from the Stamp into the "file".

From the PINK docs:
•  Nb_varEC is the email CONTENT: register.  When using the PINK to send email, this register will  hold
 the name of the file containing the content for the email message.  The file must be on the  PINK module
 prior to sending an email message.  A *.txt file will be written out as the body text  of an email message
 if indicated in the Nb_varEC variable.



How can this file get there, and/or, what is the *.txt file?

What I want to do is send text data from the Stamp to email, or post the entire content on a web page. Is that possible? The text file on the Stamp may be thousands of bytes long.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-11-05 18:46
    Tracy,

    As I understand it, the file must be present on the PINK.

    You put it on the PINK via the pc software.

    The file references variables using <Nb_varXX> that are filled in

    before sending. You may specify a *.htm file also.

    The maximum of changeable data in a file is thus limited

    to 100*63 = 6300 bytes.

    I don't think you can write a file to the PINK

    from the stamp.

    regards peter




    Post Edited (Peter Verkaik) : 11/5/2005 7:06:45 PM GMT
  • KB3JJGKB3JJG Posts: 95
    edited 2005-11-05 19:32
    As I understand it from the doc and the sample code you can write to the RAM variables with a serout..···

    from the documentation.....
    serout 8,396,[noparse][[/noparse]"!NB0W06:25",cls]·· will write the value 25 to RAM variable 6 on the PINK, I can't deduce if you can then use this in an email , my PINK is on the way so I can't test anything yet. I think a better way to accomplish this is to use the UDP functionality, break up your long string in 64 byte chunks, write them to the PINK then send them off to a server/pc for concatenation and publishing. Once I get my pink I intend on writing some tools with softwire, I will then share them with the community if I am successful. I hope UPS doesnt ban me fom their website for checking my tracking info every 5 minutes...hehe j/k
    ·
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2005-11-05 20:16
    I think I'm getting the picture. I have one of these on order too, and it looks like it is going to be a good tool for learning.

    So, the text file I have will be put in variables. The following might be a snippet to move 20 lines of data (each <64 bytes long and CRLF delimited) from the Stamp into 20 sequential variables on the netburner...

    idx VAR Word
    jdx  VAR Word
    FOR idx=20 to 39    ' suppose 20 lines in the Stamp file, each less than 64 chars and CRLF terminated
      SEROUT 8,396,[noparse][[/noparse]"!NB0W",DEC2 idx]   ' to send lines to netburner variables #20 to #39
      DO
        READ jdx,char                ' read characters for this line
        SEROUT 8,396,[noparse][[/noparse]char]
       LOOP UNTIL char=LF     ' each line ends with line feed
        SEROUT 8,396,[noparse][[/noparse]CLS]   ' this is end of line for the netburner
    NEXT       ' on to next line or continue...
    ' ...
    
    



    The file on the netburner will consist of the following types of statements:

    <Nb_var20>
    <Nb_var21>
    <Nb_var22>
    <Nb_var23>
    <Nb_var24>
    <Nb_var25>
    ...and so on...
    <Nb_var39>

    Is that close? The file structure is predetermined at ftp time from a PC, and is given a name that is called via the Nb_varEC file pointer variable. Is is there a way to make the number of lines in the file depend on a variable? What is sent if a variable is empty?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-11-05 20:37
    Tracy,

    I think that's it. The file would be a htm file (webpage format).

    I assume an empty Nb_varXX prints nothing.

    You would clear a variable by sending CLS directly afer the ':'

    You are wise to use var_20 and higher only. As I understand

    the first 20 vars·are loaded from flash upon powerup or reset,

    but I do not·yet know how to reset the PINK from the stamp,

    so best not to overwrite them, until that is clear.

    regards peter




    Post Edited (Peter Verkaik) : 11/5/2005 8:58:40 PM GMT
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-11-05 20:46
    Tracy,

    I think it is allowed to put CR and LF into the variables. So you could fill up

    variables to 63 bytes (the last byte must be CLS).

    regards peter
  • Ryan ClarkeRyan Clarke Posts: 738
    edited 2005-11-05 21:03
    Ok, first of all the 'payload' file must be on the PINK module and can be of any type. It is put there via the drag and drop FTP interface -(side note : Firefox doesn't support drag and drop, so you may have to use text based FTP to do this, or your favorite FTP software package)-

    Secondly, you can get the variables by referencing them in a webpage (if that is what you are trying to do)-

    The stamp may update the variables. (Or the variables may be updated via the web interface as well)-

    This setup is very open ended. In the even that I just wanted some text sent, I just put that in the 'file name'- in this case the email will send something to the effect of "File: (TEXT HERE)" cannot be found." - This was a quick and dirty way of just sending a simple text message, rather than the contents of a file (it helped with testing, debugging, etc)-

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Clarke
    Parallax Tech Support

    RClarke@Parallax.com
  • Ryan ClarkeRyan Clarke Posts: 738
    edited 2005-11-05 21:07
    Also, I may have a default error message, in a TXT file. If this file name is indicated, this error will be loaded- so I may use the stamp to load a particular error email if certain conditions are met. So the stamp may select the mail message to be sent. These mail messages may be dynamic, if they are HTML.

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Clarke
    Parallax Tech Support

    RClarke@Parallax.com
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2005-11-06 05:58
    Peter, I read your other post about the 20 variables (20 * 64 bytes) that load in from flash. It does seem to be a good idea to leave those for default data or metadata, that might still need to be changed at run time, and I see now that the file itself cannot be changed at run time.

    Also, okay about embedding the CRLF within the variables. By running it together, and by using all 100 variables, the body text could be up to 6400 bytes. You implied that the CLS (ascii 0 for the Stamp) is also put in the variable, at the end of the message, so there can only be 63 characters + CLS. Are you sure about that? Does that actually serve as an "end of variable" marker? Maybe it reads out to CLS or 64 bytes, whichever comes first. I wonder if it treats any of the other control characters in a special way?

    Ryan, I'm not sure what you mean when you say, "the payload file can be of any type", and also, "these mail messages may be dynamic, if they are HTML." I want the Stamp to determine the body text of the email message. It is not just a canned message. Do variables only work inside of HTML tags? For example, if I create the following file and save it as busybody.txt, and then fill up the variables from the Stamp, will the body of the message then be the content of those variables?

    <Nb_var20>
    <Nb_var21>
    <Nb_var22>
    <Nb_var23>
    <Nb_var24>
    <Nb_var25>
    




    Sorry for the untried questions. I guess I'll just have to wait until I have one of these in hand.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-11-06 21:14
    Tracy Allen said...(trimmed)
    Sorry for the untried questions. I guess I'll just have to wait until I have one of these in hand.
    Tracy,

    ·· If anyone deserves to be able to ask a bunch of questions, it's you.· As I recall you are usually the one answering them!· Ryan will be happy to answer any of these questions.· I'm sure others would benefit from it as well.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Ryan ClarkeRyan Clarke Posts: 738
    edited 2005-11-07 03:25
    Chris Savage (Parallax) said...
    Tracy Allen said...(trimmed)

    Sorry for the untried questions. I guess I'll just have to wait until I have one of these in hand.
    Tracy,


    If anyone deserves to be able to ask a bunch of questions, it's you. As I recall you are usually the one answering them! Ryan will be happy to answer any of these questions. I'm sure others would benefit from it as well.

    Hi Tracy,

    Hope this will help:

    Say I wanted to know the value of the registers in the PINK via email. I would create a file that had in the body a reference to each of the variables I'd like to see. For example, if I wanted to know the value of the file that was going to be sent via email, I'd put this in the body:

    <Nb_varEC>

    Keep in mind this could be in a *.txt file, HTML, etc...it doesn't matter. What happens is the PINK will take the 'content file' and parse it, and anywhere it sees a reference to the variable names, called out by the <> brackets, it will fill in what ever the current value of the register is.

    e.g. I just created a file called "email" (no file extension at all). In the body of that file was the folllowing:

    The value in the varEC register is: <Nb_varEC>

    (That was the only line in the file.) Then I sent an email to myself, and in the body text of that email was the following:

    The value in the varEC register is: email

    The way the emails are 'dynamic' is in that parsing that takes place. The thinking is that you can create different 'forms' such as an email for showing certain kinds of data, that only pulls on certain registers. Of course one could put ALL the registers into a mail, but then the message would be bigger.

    I hope this makes sense. If it doesn't please ask for clarification.

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Clarke
    Parallax Tech Support

    RClarke@Parallax.com
  • Ryan ClarkeRyan Clarke Posts: 738
    edited 2005-11-07 03:28
    Oh- another point- the first 20 are NOT written to flash unless you specify that they be written there. So using the first 20 is not a problem, the same as using any of your other vars. You have to manually have them written to flash to set the 'default values'-

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Clarke
    Parallax Tech Support

    RClarke@Parallax.com
  • Ryan ClarkeRyan Clarke Posts: 738
    edited 2005-11-07 03:39
    Yet one more thing:

    Say you create a file with no extension, say "testfile" - then in the body of that you have <> references to variables. When sent via email , the actual values will be reflected in place of the <> references. However, if you browse to the file (for example: http://XX.XX.XX.XX/testfile where XX.XX.XX.XX is the ip of your module)- then the page WILL NOT reflect the value, but just the text as it was originally written in the file. To have the webpage parsed and reflect the value of the variables, the file must be an HTML file. Simply changing the file extension in the example above will cause the value of the register to be displayed.

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Clarke
    Parallax Tech Support

    RClarke@Parallax.com
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-11-07 11:31
    Hi Ryan,

    Can we fill up variables to 64 bytes or only 63 and must the last byte be the CLS

    character (which is a binary 0)? What happens if we write 65 bytes to a variable?

    For udp messages:

    Since a binary 0 is used as end of variable marker, can we still use escape sequences

    to put in binary values? Say I use '\','\' for the \ character and '\','0' for the binary 0

    and a receiving stamp would be aware of that, will that work? If·binary

    byte values 1-255·have no special meaning I believe that should work.

    regards peter







    Post Edited (Peter Verkaik) : 11/7/2005 11:40:06 AM GMT
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2005-11-07 21:09
    I'd like to know about the whole ascii character set, too, with an escape sequence or substitute character for the CLS=0. That would allow for transmitting compressed data.

    Ryan, the files I want to transmit are tab delimited weather data or stuff like that, and the transmission will occur once per day, so the file will consist of some multiple of 24 lines of data.

    So if I understand this right, email or UDP is less exacting than web page display. For email or UDP, I can put any extension I want on the file, and the parser will fill in the values of the variables and I don't need any HTML tags right? However, for web page display, the variable tags have to be bracketed with valid HTML <body> etc. tags?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • rhino76rhino76 Posts: 3
    edited 2006-11-26 22:11
    Does anyone have a solution for sending email from the PINK module when your ISP requires authentication?
    i.e. I must set it up with the SMTP address and the Port and username and password. Talk about overkill!!!
    - Ryan Miller
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-11-27 00:12
    Rhino,
    ·
    ·· There is no solution other than to perhaps set up your own mail server or find an alternate. ·The PINK module firmware is not set up to do what you ask.· Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • rhino76rhino76 Posts: 3
    edited 2006-11-29 01:04
    Chris Savage said...
    ..perhaps set up your own mail server.
    Do you have any suggestions for software to do this (preferrably free). If this is a viable solution, I'd like to setup a mail server as a middle-ware to relay the message and do the authentication to my ISP's SMTP server. I guess I'm not clear on what options I have. I started looking around for mail servers that didn't require authentication, but have not come across any yet. Probably shouldn't be surprised, sounds like a good method of reducing spamming. Any help appreciated. Thanks.
    - Ryan Miller
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-11-29 15:09
    Ryan,
    ·
    ·· While I know there is mail server software available I am not familiar with any of it.· I am actually using the UDP Message feature instead.· In theory you could setup a PC Application (which you would have to write) that could take a UDP Message and send it via your normal e-mail client software.· I hope this helps.· Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • rhino76rhino76 Posts: 3
    edited 2006-11-29 17:24
    Chris Savage said...
    ....In theory you could setup a PC Application (which you would have to write) that could take a UDP Message and send it via your normal e-mail client software....
    Thanks Chris, that does help. I'm pretty sure I can do that easy enough in VB or C#. Are there any plans to address this issue, or any others that I may not be aware of, with firmware upgrades?
    - Ryan Miller
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-11-29 17:54
    It is something we can certainly look into.· Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.