Shop OBEX P1 Docs P2 Docs Learn Events
How to download A “Spin” file from the Object Exchange? — Parallax Forums

How to download A “Spin” file from the Object Exchange?

TCTC Posts: 1,019
edited 2013-05-13 11:45 in Propeller 1
I am trying to download a “Spin” file from the object exchange, but when I click on the link to download it, it does not give me a file, it gives me this:
{{ ************************************************* * Extended Full-Duplex Serial Object * * Version 1.1.0 * * Copyright (c) 2007, Martin Hebel * * See end of file for terms of use. * ************************************************* * Extended Methods for FullDuplexSerial * * by Chip Gracey, Pallax, Inc * * * * Primary Author: Martin Hebel * * Electronic Systems Technologies * * Southern Illinois University Carbondale * * www.siu.edu/~isat/est * * * * Questions? Please post on the Propeller forum * * http://forums.parallax.com/forums/ * ************************************************* This object extends Chip Gracey's FullDuplexSerial to allow easy reception of multiple bytes for decimal values, hex values and strings which end with carriage returns (ASCII 13) OR the defined delimiter character ( default is comma - , ) Use as you would FullDuplex for Rx, Tx, Start, Stop, RxTime, RxCheck, RxFlush, DEC, HEX, BIN Str **************************************************************************************************** Adds the following: x := Serial.RxDec Returns decimal string as value x := Serial.RxDecTime(ms) Returns decimal string as value with timeout x := Serial.RxHex Returns received hex string value as decimal x := Serial.RxHexTime(ms) Returns received hex string value as decimal with timeout Serial.RxStr(@myStr) Passes received string Serial.RxStrTime(ms,@myStr) Passes received string with timeout ver 1.1: SetDelimiter(char) Sets the delimiter character, such as comma or space. it is , by deafult. CR, or ASCII 13, will also be a delimiter in addition to this. x := Serial.IntOfString(@myStr) Returns the integer (whole) portion of a string "-123.456" returns -123 x := Serial.FracOfString(@myStr) Returns the fractional decimal portion of a string "-123.456" returns 456 *************************************************************************************************** CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 OBJ Serial : "Extended_FDSerial" Pub Start Serial.start(31,30,0,9600) ' Rx,Tx, Mode, Baud }} VAR Byte datain[16] Byte Delimiter OBJ ExtSerial : "FullDuplexSerial" Pub Start (RXpin, TXpin, Mode, Baud) {{ Start serial driver - starts a cog returns false if no cog available mode bit 0 = invert rx mode bit 1 = invert tx mode bit 2 = open-drain/source tx mode bit 3 = ignore tx echo on rx Serial.Start(31,30,0, 9600) }} ExtSerial.Start(RXPin, TXPin, Mode, Baud) Delimiter := "," PUB Stop '' See FullDuplex Serial Documentation ExtSerial.Stop PUB RxCheck '' See FullDuplex Serial Documentation return (ExtSerial.RxCheck) PUB RxFlush '' See FullDuplex Serial Documentation ExtSerial.RxFlush PUB Tx (data) '' See FullDuplex Serial Documentation '' Serial.tx(13) ' Send byte of data ExtSerial.tx(data) Pub Rx '' See FullDuplex Serial Documentation '' x := Serial.RX ' receives a byte of data return (ExtSerial.rx) PUB RxTime(ms) '' See FullDuplex Serial Documentation '' x:= Serial.RxTime(100) ' receive byte with 100mS timeout return (ExtSerial.RxTime(ms)) PUB str(stringptr) '' See FullDuplex Serial Documentation '' Serial.str(String("Hello World")) ' transmit a string ExtSerial.str(stringptr) PUB dec(value) '' See FullDuplex Serial Documentation '' Serial.dec(1234) ' send decimal value as chracters ExtSerial.dec(value) PUB hex(value, digits) '' See FullDuplex Serial Documentation '' Serial.hex(1234,4) ' send value as hex string for 4 digits ExtSerial.hex(value, digits) PUB bin(value, digits) '' See FullDuplex Serial Documentation '' Serial.bin(32,4) ' send value as binary string for 8 digits ExtSerial.bin(value, digits) Pub SetDelimiter(char) {{ Sets the delimiter value for string parsing. comma by default. serial.SetDelimiter(" ") 'change to a space Also always delimits using ASCII 13 (CR) }} Delimiter := char PUB rxDec : Value | place, ptr, x {{ Accepts and returns serial decimal values, such as "1234" as a number. String must end in a carriage return (ASCII 13) x:= Serial.rxDec ' accept string of digits for value }} place := 1 ptr := 0 value :=0 dataIn[ptr] := RX ptr++ repeat while (DataIn[ptr-1] <> 13) and (DataIn[ptr-1] <> Delimiter) dataIn[ptr] := RX ptr++ if ptr > 2 repeat x from (ptr-2) to 1 if (dataIn[x] => ("0")) and (datain[x] =< ("9")) value := value + ((DataIn[x]-"0") * place) place := place * 10 if (dataIn[0] => ("0")) and (datain[0] =< ("9")) value := value + (DataIn[0]-48) * place elseif dataIn[0] == "-" value := value * -1 elseif dataIn[0] == "+" value := value PUB rxDecTime(ms) :Value | place, ptr, x, temp {{ Accepts and returns serial decimal values, such as "1234" as a number with a timeout value. No data returns -1 String must end in a carriage return (ASCII 13) x := Serial.rxDecTime(100) ' accept data with timeout of 100mS }} place := 1 ptr := 0 value :=0 temp := RxTime(ms) if temp == -1 return -1 abort dataIn[ptr] := Temp ptr++ repeat while (DataIn[ptr-1] <> 13) and (DataIn[ptr-1] <> Delimiter) dataIn[ptr] := RxTime(ms) if datain[ptr] == 255 return -1 abort ptr++ if ptr > 2 repeat x from (ptr-2) to 1 if (dataIn[x] => ("0")) and (datain[x] =< ("9")) value := value + ((DataIn[x]-"0") * place) place := place * 10 if (dataIn[0] => ("0")) and (datain[0] =< ("9")) value := value + (DataIn[0]-48) * place elseif dataIn[0] == "-" value := value * -1 elseif dataIn[0] == "+" value := value PUB rxHex :Value | place, ptr, x, temp {{ Accepts and returns serial hexadecimal values, such as "A2F4" as a number. String must end in a carriage return (ASCII 13) x := Serial.rxHex ' accept string of digits for value }} place := 1 ptr := 0 value :=0 temp := Rx if temp == -1 return -1 abort dataIn[ptr] := Temp ptr++ repeat while (DataIn[ptr-1] <> 13) and (DataIn[ptr-1] <> Delimiter) dataIn[ptr] := Rx if datain[ptr] == 255 return -1 abort ptr++ if ptr > 1 repeat x from (ptr-2) to 0 if (dataIn[x] => ("0")) and (datain[x] =< ("9")) value := value + ((DataIn[x]-"0") * place) if (dataIn[x] => ("a")) and (datain[x] =< ("f")) value := value + ((DataIn[x]-"a"+10) * place) if (dataIn[x] => ("A")) and (datain[x] =< ("F")) value := value + ((DataIn[x]-"A"+10) * place) place := place * 16 PUB rxHexTime(ms) :Value | place, ptr, x, temp {{ Accepts and returns serial hexadecimal values, such as "A2F4" as a number. with a timeout value. No data returns -1 String must end in a carriage return (ASCII 13) x := Serial.rxHexTime(100) ' accept string of digits for value with 100mS timeout }} place := 1 ptr := 0 value :=0 temp := RxTime(ms) if temp == -1 return -1 abort dataIn[ptr] := Temp ptr++ repeat while (DataIn[ptr-1] <> 13) and (DataIn[ptr-1] <> Delimiter) dataIn[ptr] := RxTime(ms) if datain[ptr] == 255 return -1 abort ptr++ if ptr > 1 repeat x from (ptr-2) to 0 if (dataIn[x] => ("0")) and (datain[x] =< ("9")) value := value + ((DataIn[x]-"0") * place) if (dataIn[x] => ("a")) and (datain[x] =< ("f")) value := value + ((DataIn[x]-"a"+10) * place) if (dataIn[x] => ("A")) and (datain[x] =< ("F")) value := value + ((DataIn[x]-"A"+10) * place) place := place * 16 PUB RxStr (stringptr) : Value | ptr {{ Accepts a string of characters - up to 15 - to be passed by reference String acceptance terminates with a carriage return or the defined delimiter character. Will accept up to 15 characters before passing back. Serial.Rxstr(@MyStr) ' accept serial.str(@MyStr) ' transmit }} ptr:=0 bytefill(@dataIn,0,15) dataIn[ptr] := Rx ptr++ repeat while ((DataIn[ptr-1] <> 13) and (DataIn[ptr-1] <> Delimiter)) and (ptr < 15) dataIn[ptr] := RX ptr++ dataIn[ptr-1]:=0 byteMove(stringptr,@datain,16) PUB RxStrTime (ms,stringptr) : Value | ptr, temp {{ Accepts a string of characters - up to 15 - to be passed by reference Allow timeout value. String acceptance terminates with a carriage return or defined delimter character. Will accept up to 15 characters before passing back. Serial.RxstrTime(200,@MyStr) ' accept serial.str(@MyStr) ' transmit }} ptr:=0 bytefill(@dataIn,0,15) bytefill(stringptr,0,15) temp := RxTime(ms) if temp <> -1 dataIn[ptr] := temp ptr++ repeat while (((DataIn[ptr-1] <> 13) and (DataIn[ptr-1] <> Delimiter)) and (ptr < 15)) temp := RxTime(ms) if temp == -1 ptr++ quit dataIn[ptr] := temp ptr++ dataIn[ptr-1]:=0 byteMove(stringptr,@datain,16) PUB IntOfString (stringptr): Value | negFlag {{ Returns the integer or whole portion of a string with a decimal point. serial.RxString(@myStr)) x := serial.IntOfString(@myStr) "-123.456" will return -123 }} repeat strsize(stringptr) if byte[stringptr] == "-" negFlag := true if (byte[stringptr] => ("0")) and (byte[stringptr] =< ("9")) value := value * 10 + (byte[stringptr]-"0") if byte[stringptr] == "." if NegFlag == true value := value * -1 !negFlag quit stringptr++ if NegFlag == true value := value * -1 !negFlag PUB FracOfString (stringptr): Value | decFlag {{ Returns the fractional or decimal portion of a string with a decimal point. serial.RxString(@myStr)) x := serial.FracOfString(@myStr) "-123.456" will return 456 }} repeat strsize(stringptr) if byte[stringptr] == "." decFlag := true if decFlag == True if (byte[stringptr] => ("0")) and (byte[stringptr] =< ("9")) value := value * 10 + (byte[stringptr]-"0") stringptr++ {{ ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ TERMS OF USE: MIT License │ ├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation │ │files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, │ │modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software│ │is furnished to do so, subject to the following conditions: │ │ │ │The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.│ │ │ │THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE │ │WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR │ │COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, │ │ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ }}

Is anyone else having the same problem?

Comments

  • Heater.Heater. Posts: 21,230
    edited 2013-05-10 14:47
    No.

    When I click that exact Spin file a dialog asks me if I want to save it. I say yes and boom there is my file.

    That's using FireFox under Linux.

    What browser and OS is giving you such problems?
  • TCTC Posts: 1,019
    edited 2013-05-10 14:57
    I am using internet explorer, on a windows 7 64bit pc.

    It works with .zip files.
  • Heater.Heater. Posts: 21,230
    edited 2013-05-10 15:03
    Have a go with Chrome or FireFox.

    Presumably that code appeared as text in your browser window. I know when you post it here the formatting gets screwed up. But if it looked good in your window you could just "select all" and copy and paste it into some other editor. Job done.

    I never understood why Windows makes these simple things so hard.
  • TCTC Posts: 1,019
    edited 2013-05-10 15:08
    the formatting is right That is the way it looks. I wish it looked right, it would be easy then.

    Ill have to download chrome so I can get the file.

    Maybe it will be fixed later.

    Thank you.
  • SRLMSRLM Posts: 5,045
    edited 2013-05-10 16:03
    I don't think it's broken, but just a misinterpration. Since it's a plain text file, the browser thinks it can open it and so it does. I think if you right click on the link and choose "save as" then you'll be fine.
  • TCTC Posts: 1,019
    edited 2013-05-10 17:10
    SRLM wrote: »
    I don't think it's broken, but just a misinterpration. Since it's a plain text file, the browser thinks it can open it and so it does. I think if you right click on the link and choose "save as" then you'll be fine.

    Tried that, I dont have "save as" I have "save link as"

    Went with chrome, still cant save file, but I can copy N paste. I just hope the ones that changed the object exchange, see that there are still bugs to work out. I know thay will find them, it just takes time.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-05-10 19:26
    Same issue happens to me on Windows 7 IE 10. However, if I right click and select save target as, change file type to all and place .spin after the file name it saves as spin file and opens with prop tool. It use to be that if I opened a spin file online it would open with the prop tool. However, it looks as though my laptop just installed IE 10 a couple days ago so that could be it. I swear I shut auto updates off.
  • whickerwhicker Posts: 749
    edited 2013-05-10 23:19
    Perhaps the MIME type is incorrect on the server.
    or maybe it isn't... "application/octet-stream" should work.
    If I understand things correctly, this should force the "Save As" dialog box to show, and it should force all characters from 0-255 to be valid.

    But does internet explorer know what type="application/octet-stream; length=29606" is?

    could the semicolon and beyond be something the browser is not expecting? Then it inspects maybe the first 256 characters of the file, sees nothing but characters in the ascii range, so then just treats it as a text file?

    really, what's with the "; length=" tacked on there?
  • Heater.Heater. Posts: 21,230
    edited 2013-05-11 00:25
    whicker,

    Where are you getting that content type from? I see no such header in the http response:
    $ curl -i http://obex.parallax.com/sites/default/files/obj/id/227/Extended_FDSerial.spin
    HTTP/1.1 200 OK
    Date: Sat, 11 May 2013 07:21:26 GMT
    Server: Apache/2.2.22 (Ubuntu)
    Last-Modified: Fri, 05 Apr 2013 16:38:37 GMT
    ETag: "20ec8-73a6-4d99fb80fb344"
    Accept-Ranges: bytes
    Content-Length: 29606
    
    &#65533;&#65533;{{
      *************************************************
      *  Extended Full-Duplex Serial Object           *
      *  Version 1.1.0                                *
    .
    .
    .
    
  • whickerwhicker Posts: 749
    edited 2013-05-11 01:12
    Heater,

    that's probably the core of the problem is that the server doesn't have a top-level mime-type (since you accessed the resource directly)

    However, what I was doing was inspecting the source code of the webpage that links to the file.
    the anchor element "<a>" has a type="" tag in it. this is apparently allowed nowadays.
    <span class="file">
    <img class="file-icon" src="/modules/file/icons/application-octet-stream.png" title="application/octet-stream" alt=""></img>
    <a type="application/octet-stream; length=29606" href="http://obex.parallax.com/sites/default/files/obj/id/227/Extended_FDSerial.spin"></a>
    </span>
    
  • Heater.Heater. Posts: 21,230
    edited 2013-05-11 03:06
    w3schools says about the type attribute: "Note: This attribute is purely advisory."

    Now I see what you mean. What is that "; length=29606" doing in there?

    Looks like a bug to me.
  • Mike GMike G Posts: 2,702
    edited 2013-05-11 08:33
    The type attribute application/octet-stream tells the browser to open the file as an attachment. Whatever program is mapped to .spin will open. Similar to double clicking a file. If there are no mappings, the browser will render the stream.

    I'm more familiar with using a header content-type: application/octet-stream to invoke the same behavior.

    Associate .spin to the Propeller Tool or Spin editor of your choice.
  • ProcessingData...ProcessingData... Posts: 208
    edited 2013-05-11 08:44
    Another header that can help to "force" a download is
    [PHP]Content-disposition: attachment; filename=Object.spin[/PHP]

    This has the added benefit of allowing you to rename the file on the fly, so you could use PHP or another language to grab and print the file data.
  • Heater.Heater. Posts: 21,230
    edited 2013-05-11 12:03
    Except a type attribute on a link does not tell the browser to do anything. The standard says "This attribute is purely advisory."
  • Mike GMike G Posts: 2,702
    edited 2013-05-11 12:47
    Heater, you're correct... this is what the RFC says.
    The "type" parameter, when present, is a hint indicating what the
    media type of the result of dereferencing the link should be. Note
    that this is only a hint; for example, it does not override the
    Content-Type header of a HTTP response obtained by actually following
    the link. There MUST NOT be more than one type parameter in a link-
    value

    This is the header returned from the web server. There is no Content-Type: so I image IE does not know what to do. FireFox has no problem making the connection.
    HTTP/1.1 200 OK
    Date:		Sat, 11 May 2013 19:20:01 GMT
    Server:		Apache/2.2.22 (Ubuntu)
    Last-Modified:	Fri, 05 Apr 2013 16:38:37 GMT
    Etag:		"20ec8-73a6-4d99fb80fb344"
    Accept-Ranges:	bytes
    Content-Length:	29606
    Keep-Alive:	timeout=5, max=100
    Connection:	Keep-Alive
    

    I've seen this situation many times working with the Spinneret and W5200 usually because I messed something up.

    Moral - use something other than IE. If you must use IE then right click and select "Save link as..." Or maybe zip the file on upload to the OBEX.
  • TCTC Posts: 1,019
    edited 2013-05-11 16:26
    Mike G wrote: »

    Moral - use something other than IE. If you must use IE then right click and select "Save link as..." Or maybe zip the file on upload to the OBEX.

    I only have one complaint about this. For me I don’t have a problem right clicking, but what about the kids/people that are just getting started and trying to learn? They click on the link (that should open a window that allows them to save) and all they get is a page with run on lines, it could be overwhelming, and possibility discourages them from using that file to learn from.

    Sometimes I feel like some people don’t understand that not everyone likes to use other web browsers (Like me, I’m happy with IE), or that don’t know there are other options out there that are trustworthy enough not to put god only knows how much Smile on your PC.

    And why does things have to be complicated? Why is it that if you are looking for something, you have to click link after link just to find out info? I believe some people have gotten lazy, and don’t want to put the effort into making something easy for beginners or people with short attention spans. That is why I like parallax; everything is easy to find, and to understand. The PROP manual needs a little work, but it’s ok.

    Sorry for my rant.
  • tritoniumtritonium Posts: 543
    edited 2013-05-11 16:33
    Hi
    In google chrome - save link as....
    in win explorer - save object as....
    By the way - in the reply message box it seems line feed has stopped working!!
    Created this in notepad and pasted...
    dave
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2013-05-11 18:25
    Attached is the file you need.

    Others have probably already worked this out, but it seems the problem is the file was stored on the obex as a .spin file and it really ought to be stored as a .zip file, even if it contains just one file.

    So - doing all this in Opera...

    * Go to the obex
    * Search for "full duplex"
    * Click on the link
    * Opera opens a new page full of text
    * Click Ctrl A (yea, I know, ancient DOS stuff)
    * Click Ctrl C
    * Open the Propeller Tool
    * Click Ctrl V and check the formatting hasn't been corrupted, the spaces are all there etc
    * Save the file from the Propeller Tool as a spin file
    * My Computer/My Documents (where I saved it), right click and Send To a .zip file (this is Win 8, in older versions might need to use Winzip or similar).
    * Post here and ask some kind soul to put this .zip file into the obex instead of the .spin one

    Problem solved... for this file.

    Looking back, I agree, this isn't very simple.

    I wonder if the Obex might pop up a message when an author is uploading saying that it prefers .zip files?
  • Heater.Heater. Posts: 21,230
    edited 2013-05-12 02:49
    TC,
    And why does things have to be complicated?
    A very good question.
    When you look at what makes up web technology you start to wonder how it manages to function at all. HTML, CSS, JavaScript in the web page, PHP, templating, MySql, etc etc going on in the server. All that HTTP stuff. All those different browsers doing things their own way.

    I have some beefs with the forum recently.
    1) Hitting "Quick Reply" hangs up in one of my browsers (Chrome) on one machine. The others are OK.
    2) As noted above, line feeds get removed reducing your post to a run on mess. This is sometimes so and sometimes not.
    3) The Icons on above the edit box don't show up sometimes. (I think it's the same chrome as 1) above.
  • Jeff MartinJeff Martin Posts: 758
    edited 2013-05-13 11:45
    Thanks for noting this, and for all the helpful responses! We'll see if there's something we can do on our side that makes it better, but we did not see this problem on our side before or we'd have addressed it.

    Also, thanks for the "rant" about complexity vs. simplicity, and Prop Manual also. We always try to make things easy unless we know a target customer is not expecting that; it's a tough thing to do sometimes, but we strive for it.
Sign In or Register to comment.