<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[SoliForum - 3D Printing Community — Question about Arduino install, stuck]]></title>
		<link>https://www.soliforum.com/topic/3864/question-about-arduino-install-stuck/</link>
		<atom:link href="https://www.soliforum.com/feed/rss/topic/3864/" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Question about Arduino install, stuck.]]></description>
		<lastBuildDate>Sat, 23 Nov 2013 19:55:41 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Question about Arduino install, stuck]]></title>
			<link>https://www.soliforum.com/post/42343/#p42343</link>
			<description><![CDATA[<p>when i try to compile, i get a compiling error.</p><p>C:\Users\Matt\AppData\Local\Temp\build7052610623013338738.tmp\core.a(main.cpp.o): In function `main&#039;:<br />C:\Users\Matt\Desktop\arduino-0022\hardware\at90usb1286\cores\at90usb1286/main.cpp:6: undefined reference to `setup&#039;<br />C:\Users\Matt\Desktop\arduino-0022\hardware\at90usb1286\cores\at90usb1286/main.cpp:8: undefined reference to `loop&#039;<br />&nbsp; is what is in red in the output text<br />i am using the arduino 0022 that has the preconfigured solidoodle printrboard settings in it.&nbsp; i have the correct com port selected and i have tried this with both of the printrboard settings in arduino, the tinyusbisp and the one for bootloader cdc</p>]]></description>
			<author><![CDATA[null@example.com (mattio79)]]></author>
			<pubDate>Sat, 23 Nov 2013 19:55:41 +0000</pubDate>
			<guid>https://www.soliforum.com/post/42343/#p42343</guid>
		</item>
		<item>
			<title><![CDATA[Re: Question about Arduino install, stuck]]></title>
			<link>https://www.soliforum.com/post/36139/#p36139</link>
			<description><![CDATA[<p>Wow, neat idea. Thanks, Shan.</p>]]></description>
			<author><![CDATA[null@example.com (Heartlander)]]></author>
			<pubDate>Thu, 12 Sep 2013 23:52:10 +0000</pubDate>
			<guid>https://www.soliforum.com/post/36139/#p36139</guid>
		</item>
		<item>
			<title><![CDATA[Re: Question about Arduino install, stuck]]></title>
			<link>https://www.soliforum.com/post/36129/#p36129</link>
			<description><![CDATA[<p>Not really helpful to the ACTUAL topic at hand; but for future reference you can use the CODE bbtag (there is a button that looks like &quot;&lt;&gt;&quot; when you compose a message) that anything you put within it is put into a scroll-box so the thread doesn&#039;t get massively long.&nbsp; For example, this is MarlinSerial.H</p><p>I&#039;m not being critical; just informative <img src="https://www.soliforum.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><div class="codebox"><pre><code>/*
  HardwareSerial.h - Hardware serial library for Wiring
  Copyright (c) 2006 Nicholas Zambetti.  All right reserved.
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.
  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.
  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  Modified 28 September 2010 by Mark Sproul
*/
#ifndef MarlinSerial_h
#define MarlinSerial_h
#include &quot;Marlin.h&quot;
#if !defined(SERIAL_PORT) 
#define SERIAL_PORT 0
#endif
// The presence of the UBRRH register is used to detect a UART.
#define UART_PRESENT(port) ((port == 0 &amp;&amp; (defined(UBRRH) || defined(UBRR0H))) || \
                        (port == 1 &amp;&amp; defined(UBRR1H)) || (port == 2 &amp;&amp; defined(UBRR2H)) || \
                        (port == 3 &amp;&amp; defined(UBRR3H)))                
                        
// These are macros to build serial port register names for the selected SERIAL_PORT (C preprocessor
// requires two levels of indirection to expand macro values properly)
#define SERIAL_REGNAME(registerbase,number,suffix) SERIAL_REGNAME_INTERNAL(registerbase,number,suffix)
#if SERIAL_PORT == 0 &amp;&amp; (!defined(UBRR0H) || !defined(UDR0)) // use un-numbered registers if necessary
#define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##suffix
#else
#define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix
#endif
// Registers used by MarlinSerial class (these are expanded 
// depending on selected serial port
#define M_UCSRxA SERIAL_REGNAME(UCSR,SERIAL_PORT,A) // defines M_UCSRxA to be UCSRnA where n is the serial port number
#define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B) 
#define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,)    
#define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,)    
#define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,)    
#define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,)    
#define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,)  
#define M_UBRRxH SERIAL_REGNAME(UBRR,SERIAL_PORT,H)
#define M_UBRRxL SERIAL_REGNAME(UBRR,SERIAL_PORT,L)
#define M_RXCx SERIAL_REGNAME(RXC,SERIAL_PORT,)
#define M_USARTx_RX_vect SERIAL_REGNAME(USART,SERIAL_PORT,_RX_vect)
#define M_U2Xx SERIAL_REGNAME(U2X,SERIAL_PORT,)


#define DEC 10
#define HEX 16
#define OCT 8
#define BIN 2
#define BYTE 0

#ifndef AT90USB
// Define constants and variables for buffering incoming serial data.  We&#039;re
// using a ring buffer (I think), in which rx_buffer_head is the index of the
// location to which to write the next incoming character and rx_buffer_tail
// is the index of the location from which to read.
#define RX_BUFFER_SIZE 128

struct ring_buffer
{
  unsigned char buffer[RX_BUFFER_SIZE];
  int head;
  int tail;
};
#if UART_PRESENT(SERIAL_PORT)
  extern ring_buffer rx_buffer;
#endif
class MarlinSerial //: public Stream
{
  public:
    MarlinSerial();
    void begin(long);
    void end();
    int peek(void);
    int read(void);
    void flush(void);
    
    FORCE_INLINE int available(void)
    {
      return (unsigned int)(RX_BUFFER_SIZE + rx_buffer.head - rx_buffer.tail) % RX_BUFFER_SIZE;
    }
    
    FORCE_INLINE void write(uint8_t c)
    {
      while (!((M_UCSRxA) &amp; (1 &lt;&lt; M_UDREx)))
        ;
      M_UDRx = c;
    }
    
    
    FORCE_INLINE void checkRx(void)
    {
      if((M_UCSRxA &amp; (1&lt;&lt;M_RXCx)) != 0) {
        unsigned char c  =  M_UDRx;
        int i = (unsigned int)(rx_buffer.head + 1) % RX_BUFFER_SIZE;
        // if we should be storing the received character into the location
        // just before the tail (meaning that the head would advance to the
        // current location of the tail), we&#039;re about to overflow the buffer
        // and so we don&#039;t write the character or advance the head.
        if (i != rx_buffer.tail) {
          rx_buffer.buffer[rx_buffer.head] = c;
          rx_buffer.head = i;
        }
      }
    }
    
    
    private:
    void printNumber(unsigned long, uint8_t);
    void printFloat(double, uint8_t);
    
    
  public:
    
    FORCE_INLINE void write(const char *str)
    {
      while (*str)
        write(*str++);
    }

    FORCE_INLINE void write(const uint8_t *buffer, size_t size)
    {
      while (size--)
        write(*buffer++);
    }
    FORCE_INLINE void print(const String &amp;s)
    {
      for (int i = 0; i &lt; (int)s.length(); i++) {
        write(s);
      }
    }
    
    FORCE_INLINE void print(const char *str)
    {
      write(str);
    }
    void print(char, int = BYTE);
    void print(unsigned char, int = BYTE);
    void print(int, int = DEC);
    void print(unsigned int, int = DEC);
    void print(long, int = DEC);
    void print(unsigned long, int = DEC);
    void print(double, int = 2);
    void println(const String &amp;s);
    void println(const char[]);
    void println(char, int = BYTE);
    void println(unsigned char, int = BYTE);
    void println(int, int = DEC);
    void println(unsigned int, int = DEC);
    void println(long, int = DEC);
    void println(unsigned long, int = DEC);
    void println(double, int = 2);
    void println(void);
};
extern MarlinSerial MSerial;
#endif // !AT90USB
#endif&quot;</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (shan.destromp)]]></author>
			<pubDate>Thu, 12 Sep 2013 22:51:12 +0000</pubDate>
			<guid>https://www.soliforum.com/post/36129/#p36129</guid>
		</item>
		<item>
			<title><![CDATA[Re: Question about Arduino install, stuck]]></title>
			<link>https://www.soliforum.com/post/36103/#p36103</link>
			<description><![CDATA[<p>It is nonsense like that that led me to dig up what the IDE does and use the equivalent commands manually or from makefiles.</p>]]></description>
			<author><![CDATA[null@example.com (Claghorn)]]></author>
			<pubDate>Thu, 12 Sep 2013 19:52:23 +0000</pubDate>
			<guid>https://www.soliforum.com/post/36103/#p36103</guid>
		</item>
		<item>
			<title><![CDATA[Re: Question about Arduino install, stuck]]></title>
			<link>https://www.soliforum.com/post/36094/#p36094</link>
			<description><![CDATA[<p>Hunter Green, I am tweaking what Jason just said so you can plug this into the tutorial you&#039;re compiling:</p><p>To find your firmware.cpp.hex file you need to look at the information the compile put out. </p><p>You have to use the &quot;verbose&quot; compile to see this. The Arduino menu says you can press SHIFT while clicking Sketch&gt;Verify/Compile but I couldn&#039;t get the verbose output to work. Instead, I went to the Arduino&#039;s File&gt;Preferences option and clicked on the link for additional preferences. Now, you need to open the Preferences.Txt file with Arduino closed. Once you have it open (in Notepad) add the line &quot;build.verbose=true&quot; (without the quotation marks) at the bottom of the file and Save it. Reopen Arduino, the select Sketch&gt;Verify/Compile the configuration.h and it will display the output information at the bottom of the Arduino screen.</p><p>It will be in a location like C:\Users\Kent\AppData\Local\Temp\build8020340528660499036.tmp\Solidoodle3_6142013.cpp.hex </p><p>Unzip the <a href="http://blog.lincomatic.com/wp-content/uploads/2012/03/BootloaderHID.zip">http://blog.lincomatic.com/wp-content/u … derHID.zip</a>, locate the file generated above, copy it into the hidbootloader directory.&nbsp; </p><br /><p>Unplug the main powercord from the printer/leave the usb plugged in. Hold a screwdriver to the boot jumpers and hit reset button. </p><p>Open the command prompt (Run&gt;Cmd.exe).&nbsp; Browse to your Hidbootloader folder.&nbsp; </p><p>Run the command:<br />hid_bootloader_cli -mmcu=at90usb1286 -w -v Solidoodle3_6142013.cpp.hex </p><p>If it says you are good then good, however it may say something about waiting on reset.&nbsp; If it does go through the procedure with the screwdriver, and reset button again and it will finish.</p><p>When it says its done unplug and replug the usb then plug the power cord in.</p><p>Your done.</p>]]></description>
			<author><![CDATA[null@example.com (Heartlander)]]></author>
			<pubDate>Thu, 12 Sep 2013 18:55:37 +0000</pubDate>
			<guid>https://www.soliforum.com/post/36094/#p36094</guid>
		</item>
		<item>
			<title><![CDATA[Re: Question about Arduino install, stuck]]></title>
			<link>https://www.soliforum.com/post/36067/#p36067</link>
			<description><![CDATA[<p>I&#039;m pretty sure its a totally different process with the Sang</p><p>To find your firmware.cpp.hex file you need to look at the information the compile put out&nbsp; (You have to hold shift or maybe ctl to see this it tells you in the instructions).</p><p>It will be in a location like c:\Users\Yourusername\Appdata\Local\</p><p>and it won&#039;t actually be called firmware.cpp.hex you have to read the information to get the filename, it will be the only cpp.hex file referenced though.</p><p>Unzip the HIDbootloader, locate the file generated above copy it into the hidbootloader directory.&nbsp; I chose to rename the file to firmware.cpp.hex to make it easier.&nbsp; Unplug the main powercord from the printer/leave the usb plugged in. Hold a screwdriver to the boot jumpers and hit reset button.&nbsp; </p><p>Open the command prompt.&nbsp; Browse to your Hidbootloader folder.&nbsp; Run the command in the instructions (they assume you renamed your file to firmware.cpp.hex)&nbsp; If it says you are good then good, however it may say something about waiting on reset.&nbsp; If it does go through the procedure with the screwdriver, and reset button again and it will finish.</p><br /><p>When it says its done unplug and replug the usb then plug the power cord in</p><p>Your done</p>]]></description>
			<author><![CDATA[null@example.com (jason_)]]></author>
			<pubDate>Thu, 12 Sep 2013 16:22:25 +0000</pubDate>
			<guid>https://www.soliforum.com/post/36067/#p36067</guid>
		</item>
		<item>
			<title><![CDATA[Re: Question about Arduino install, stuck]]></title>
			<link>https://www.soliforum.com/post/36066/#p36066</link>
			<description><![CDATA[<p>You shouldn&#039;t have to mess with the Bootloader.</p><p>Make the configuration.h changes in the Arduino IDE, save them, hit the reset button on the board and hit Upload.</p><p>You shouldn&#039;t have to mess with the jumper.</p><p>Though I&#039;m basing this information on my experience with the Sanguino board, not Printrboard.</p>]]></description>
			<author><![CDATA[null@example.com (3d-oodler)]]></author>
			<pubDate>Thu, 12 Sep 2013 16:06:41 +0000</pubDate>
			<guid>https://www.soliforum.com/post/36066/#p36066</guid>
		</item>
		<item>
			<title><![CDATA[Re: Question about Arduino install, stuck]]></title>
			<link>https://www.soliforum.com/post/36054/#p36054</link>
			<description><![CDATA[<p>All right, I made the change to configuration.h to make the max temp 350. I compiled it. When I look st the folder, only configuration.h shows a change on the date time stamp, is that correct?</p><p>I am getting confused now on which instructions to follow. Am I ready to upload the firmware with the HID bootloader?</p><p>If so, is this next part correct?:<br />- Download Lincomatic&#039;s BootloaderHID.zip and extract the files.<br />- Move the firmware.cpp.hex file from the previous section into the BootloaderHID folder.<br />&nbsp; <br />(I cannot find the firmware.cpp.hex file. Where, oh where, could it be?)</p><p>- Connect your motherboard to your PC via USB. Add a jumper to the BOOT pins and press the RESET button to reset into bootloader mode. If you do not have a jumper, just short the pins together and press reset.</p><p>- Open a command prompt window. Navigate to BootloaderHID folder in the comand promt window and type the following command, substituting your file in for &quot;firmware.cpp.hex&quot;:<br />hid_bootloader_cli -mmcu=at90usb1286 -w -v firmware.cpp.hex</p><p>Your firmware should upload to your motherboard very quickly before resetting.</p><p>Is that it? All done?</p>]]></description>
			<author><![CDATA[null@example.com (Heartlander)]]></author>
			<pubDate>Thu, 12 Sep 2013 15:35:47 +0000</pubDate>
			<guid>https://www.soliforum.com/post/36054/#p36054</guid>
		</item>
		<item>
			<title><![CDATA[Re: Question about Arduino install, stuck]]></title>
			<link>https://www.soliforum.com/post/36005/#p36005</link>
			<description><![CDATA[<p>Hey, an answer I know! Woo hoo! No, it is different. Thank you Hazer, I feel better now.</p><p>And thank you, 2N and Jason. I see a light.</p>]]></description>
			<author><![CDATA[null@example.com (Heartlander)]]></author>
			<pubDate>Wed, 11 Sep 2013 23:24:43 +0000</pubDate>
			<guid>https://www.soliforum.com/post/36005/#p36005</guid>
		</item>
		<item>
			<title><![CDATA[Re: Question about Arduino install, stuck]]></title>
			<link>https://www.soliforum.com/post/36004/#p36004</link>
			<description><![CDATA[<p>I cannot remember, is the thermistor the same on the E3D as the stock?</p>]]></description>
			<author><![CDATA[null@example.com (Hazer)]]></author>
			<pubDate>Wed, 11 Sep 2013 23:21:58 +0000</pubDate>
			<guid>https://www.soliforum.com/post/36004/#p36004</guid>
		</item>
		<item>
			<title><![CDATA[Re: Question about Arduino install, stuck]]></title>
			<link>https://www.soliforum.com/post/36002/#p36002</link>
			<description><![CDATA[<p>like 2n2r5 said all you have to do is edit the <br />#define HEATER_0_MAXTEMP 230<br />replace the 230 with whatever you want your max temp to be</p><p>Caution however do not edit this with notepad or wordpad, edit and save the file from the Arduino IDE!</p>]]></description>
			<author><![CDATA[null@example.com (jason_)]]></author>
			<pubDate>Wed, 11 Sep 2013 22:53:58 +0000</pubDate>
			<guid>https://www.soliforum.com/post/36002/#p36002</guid>
		</item>
		<item>
			<title><![CDATA[Re: Question about Arduino install, stuck]]></title>
			<link>https://www.soliforum.com/post/36000/#p36000</link>
			<description><![CDATA[<p>#define HEATER_0_MAXTEMP 230 &lt;---- this goes to 350 in configuration.h</p>]]></description>
			<author><![CDATA[null@example.com (2n2r5)]]></author>
			<pubDate>Wed, 11 Sep 2013 22:51:08 +0000</pubDate>
			<guid>https://www.soliforum.com/post/36000/#p36000</guid>
		</item>
		<item>
			<title><![CDATA[Re: Question about Arduino install, stuck]]></title>
			<link>https://www.soliforum.com/post/35997/#p35997</link>
			<description><![CDATA[<p>It doesn&#039;t look like we do anything in Marlin_Main.cpp either.</p>]]></description>
			<author><![CDATA[null@example.com (Heartlander)]]></author>
			<pubDate>Wed, 11 Sep 2013 22:27:56 +0000</pubDate>
			<guid>https://www.soliforum.com/post/35997/#p35997</guid>
		</item>
		<item>
			<title><![CDATA[Re: Question about Arduino install, stuck]]></title>
			<link>https://www.soliforum.com/post/35996/#p35996</link>
			<description><![CDATA[<p>Don&#039;t know if we need to do anything here or not. Here&#039;s MarlinSerial.H:</p><p>/*<br />&nbsp; HardwareSerial.h - Hardware serial library for Wiring<br />&nbsp; Copyright (c) 2006 Nicholas Zambetti.&nbsp; All right reserved.</p><p>&nbsp; This library is free software; you can redistribute it and/or<br />&nbsp; modify it under the terms of the GNU Lesser General Public<br />&nbsp; License as published by the Free Software Foundation; either<br />&nbsp; version 2.1 of the License, or (at your option) any later version.</p><p>&nbsp; This library is distributed in the hope that it will be useful,<br />&nbsp; but WITHOUT ANY WARRANTY; without even the implied warranty of<br />&nbsp; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&nbsp; See the GNU<br />&nbsp; Lesser General Public License for more details.</p><p>&nbsp; You should have received a copy of the GNU Lesser General Public<br />&nbsp; License along with this library; if not, write to the Free Software<br />&nbsp; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA&nbsp; 02110-1301&nbsp; USA</p><p>&nbsp; Modified 28 September 2010 by Mark Sproul<br />*/</p><p>#ifndef MarlinSerial_h<br />#define MarlinSerial_h<br />#include &quot;Marlin.h&quot;</p><p>#if !defined(SERIAL_PORT) <br />#define SERIAL_PORT 0<br />#endif</p><p>// The presence of the UBRRH register is used to detect a UART.<br />#define UART_PRESENT(port) ((port == 0 &amp;&amp; (defined(UBRRH) || defined(UBRR0H))) || \<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (port == 1 &amp;&amp; defined(UBRR1H)) || (port == 2 &amp;&amp; defined(UBRR2H)) || \<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (port == 3 &amp;&amp; defined(UBRR3H)))&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />// These are macros to build serial port register names for the selected SERIAL_PORT (C preprocessor<br />// requires two levels of indirection to expand macro values properly)<br />#define SERIAL_REGNAME(registerbase,number,suffix) SERIAL_REGNAME_INTERNAL(registerbase,number,suffix)<br />#if SERIAL_PORT == 0 &amp;&amp; (!defined(UBRR0H) || !defined(UDR0)) // use un-numbered registers if necessary<br />#define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##suffix<br />#else<br />#define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix<br />#endif</p><p>// Registers used by MarlinSerial class (these are expanded <br />// depending on selected serial port<br />#define M_UCSRxA SERIAL_REGNAME(UCSR,SERIAL_PORT,A) // defines M_UCSRxA to be UCSRnA where n is the serial port number<br />#define M_UCSRxB SERIAL_REGNAME(UCSR,SERIAL_PORT,B) <br />#define M_RXENx SERIAL_REGNAME(RXEN,SERIAL_PORT,)&nbsp; &nbsp; <br />#define M_TXENx SERIAL_REGNAME(TXEN,SERIAL_PORT,)&nbsp; &nbsp; <br />#define M_RXCIEx SERIAL_REGNAME(RXCIE,SERIAL_PORT,)&nbsp; &nbsp; <br />#define M_UDREx SERIAL_REGNAME(UDRE,SERIAL_PORT,)&nbsp; &nbsp; <br />#define M_UDRx SERIAL_REGNAME(UDR,SERIAL_PORT,)&nbsp; <br />#define M_UBRRxH SERIAL_REGNAME(UBRR,SERIAL_PORT,H)<br />#define M_UBRRxL SERIAL_REGNAME(UBRR,SERIAL_PORT,L)<br />#define M_RXCx SERIAL_REGNAME(RXC,SERIAL_PORT,)<br />#define M_USARTx_RX_vect SERIAL_REGNAME(USART,SERIAL_PORT,_RX_vect)<br />#define M_U2Xx SERIAL_REGNAME(U2X,SERIAL_PORT,)</p><br /><br /><p>#define DEC 10<br />#define HEX 16<br />#define OCT 8<br />#define BIN 2<br />#define BYTE 0</p><br /><p>#ifndef AT90USB<br />// Define constants and variables for buffering incoming serial data.&nbsp; We&#039;re<br />// using a ring buffer (I think), in which rx_buffer_head is the index of the<br />// location to which to write the next incoming character and rx_buffer_tail<br />// is the index of the location from which to read.<br />#define RX_BUFFER_SIZE 128</p><br /><p>struct ring_buffer<br />{<br />&nbsp; unsigned char buffer[RX_BUFFER_SIZE];<br />&nbsp; int head;<br />&nbsp; int tail;<br />};</p><p>#if UART_PRESENT(SERIAL_PORT)<br />&nbsp; extern ring_buffer rx_buffer;<br />#endif</p><p>class MarlinSerial //: public Stream<br />{</p><p>&nbsp; public:<br />&nbsp; &nbsp; MarlinSerial();<br />&nbsp; &nbsp; void begin(long);<br />&nbsp; &nbsp; void end();<br />&nbsp; &nbsp; int peek(void);<br />&nbsp; &nbsp; int read(void);<br />&nbsp; &nbsp; void flush(void);<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; FORCE_INLINE int available(void)<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; return (unsigned int)(RX_BUFFER_SIZE + rx_buffer.head - rx_buffer.tail) % RX_BUFFER_SIZE;<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; FORCE_INLINE void write(uint8_t c)<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; while (!((M_UCSRxA) &amp; (1 &lt;&lt; M_UDREx)))<br />&nbsp; &nbsp; &nbsp; &nbsp; ;</p><p>&nbsp; &nbsp; &nbsp; M_UDRx = c;<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; <br />&nbsp; &nbsp; FORCE_INLINE void checkRx(void)<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; if((M_UCSRxA &amp; (1&lt;&lt;M_RXCx)) != 0) {<br />&nbsp; &nbsp; &nbsp; &nbsp; unsigned char c&nbsp; =&nbsp; M_UDRx;<br />&nbsp; &nbsp; &nbsp; &nbsp; int i = (unsigned int)(rx_buffer.head + 1) % RX_BUFFER_SIZE;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; // if we should be storing the received character into the location<br />&nbsp; &nbsp; &nbsp; &nbsp; // just before the tail (meaning that the head would advance to the<br />&nbsp; &nbsp; &nbsp; &nbsp; // current location of the tail), we&#039;re about to overflow the buffer<br />&nbsp; &nbsp; &nbsp; &nbsp; // and so we don&#039;t write the character or advance the head.<br />&nbsp; &nbsp; &nbsp; &nbsp; if (i != rx_buffer.tail) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rx_buffer.buffer[rx_buffer.head] = c;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rx_buffer.head = i;<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; <br />&nbsp; &nbsp; private:<br />&nbsp; &nbsp; void printNumber(unsigned long, uint8_t);<br />&nbsp; &nbsp; void printFloat(double, uint8_t);<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; <br />&nbsp; public:<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; FORCE_INLINE void write(const char *str)<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; while (*str)<br />&nbsp; &nbsp; &nbsp; &nbsp; write(*str++);<br />&nbsp; &nbsp; }</p><br /><p>&nbsp; &nbsp; FORCE_INLINE void write(const uint8_t *buffer, size_t size)<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; while (size--)<br />&nbsp; &nbsp; &nbsp; &nbsp; write(*buffer++);<br />&nbsp; &nbsp; }</p><p>&nbsp; &nbsp; FORCE_INLINE void print(const String &amp;s)<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; for (int i = 0; i &lt; (int)s.length(); i++) {<br />&nbsp; &nbsp; &nbsp; &nbsp; write(s<em>);<br />&nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; FORCE_INLINE void print(const char *str)<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; write(str);<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; void print(char, int = BYTE);<br />&nbsp; &nbsp; void print(unsigned char, int = BYTE);<br />&nbsp; &nbsp; void print(int, int = DEC);<br />&nbsp; &nbsp; void print(unsigned int, int = DEC);<br />&nbsp; &nbsp; void print(long, int = DEC);<br />&nbsp; &nbsp; void print(unsigned long, int = DEC);<br />&nbsp; &nbsp; void print(double, int = 2);</em></p><p><em>&nbsp; &nbsp; void println(const String &amp;s);<br />&nbsp; &nbsp; void println(const char[]);<br />&nbsp; &nbsp; void println(char, int = BYTE);<br />&nbsp; &nbsp; void println(unsigned char, int = BYTE);<br />&nbsp; &nbsp; void println(int, int = DEC);<br />&nbsp; &nbsp; void println(unsigned int, int = DEC);<br />&nbsp; &nbsp; void println(long, int = DEC);<br />&nbsp; &nbsp; void println(unsigned long, int = DEC);<br />&nbsp; &nbsp; void println(double, int = 2);<br />&nbsp; &nbsp; void println(void);<br />};</em></p><p><em>extern MarlinSerial MSerial;<br />#endif // !AT90USB</em></p><p><em>#endif&quot;</em></p>]]></description>
			<author><![CDATA[null@example.com (Heartlander)]]></author>
			<pubDate>Wed, 11 Sep 2013 22:24:07 +0000</pubDate>
			<guid>https://www.soliforum.com/post/35996/#p35996</guid>
		</item>
		<item>
			<title><![CDATA[Re: Question about Arduino install, stuck]]></title>
			<link>https://www.soliforum.com/post/35994/#p35994</link>
			<description><![CDATA[<p>Here&#039;s MarlinSerial.cpp:</p><p>/*<br />&nbsp; HardwareSerial.cpp - Hardware serial library for Wiring<br />&nbsp; Copyright (c) 2006 Nicholas Zambetti.&nbsp; All right reserved.</p><p>&nbsp; This library is free software; you can redistribute it and/or<br />&nbsp; modify it under the terms of the GNU Lesser General Public<br />&nbsp; License as published by the Free Software Foundation; either<br />&nbsp; version 2.1 of the License, or (at your option) any later version.</p><p>&nbsp; This library is distributed in the hope that it will be useful,<br />&nbsp; but WITHOUT ANY WARRANTY; without even the implied warranty of<br />&nbsp; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&nbsp; See the GNU<br />&nbsp; Lesser General Public License for more details.</p><p>&nbsp; You should have received a copy of the GNU Lesser General Public<br />&nbsp; License along with this library; if not, write to the Free Software<br />&nbsp; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA&nbsp; 02110-1301&nbsp; USA<br />&nbsp; <br />&nbsp; Modified 23 November 2006 by David A. Mellis<br />&nbsp; Modified 28 September 2010 by Mark Sproul<br />*/</p><p>#include &quot;Marlin.h&quot;<br />#include &quot;MarlinSerial.h&quot;</p><p>#ifndef AT90USB<br />// this next line disables the entire HardwareSerial.cpp, <br />// this is so I can support Attiny series and any other chip without a uart<br />#if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H)</p><p>#if UART_PRESENT(SERIAL_PORT)<br />&nbsp; ring_buffer rx_buffer&nbsp; =&nbsp; { { 0 }, 0, 0 };<br />#endif</p><p>FORCE_INLINE void store_char(unsigned char c)<br />{<br />&nbsp; int i = (unsigned int)(rx_buffer.head + 1) % RX_BUFFER_SIZE;</p><p>&nbsp; // if we should be storing the received character into the location<br />&nbsp; // just before the tail (meaning that the head would advance to the<br />&nbsp; // current location of the tail), we&#039;re about to overflow the buffer<br />&nbsp; // and so we don&#039;t write the character or advance the head.<br />&nbsp; if (i != rx_buffer.tail) {<br />&nbsp; &nbsp; rx_buffer.buffer[rx_buffer.head] = c;<br />&nbsp; &nbsp; rx_buffer.head = i;<br />&nbsp; }<br />}</p><br /><p>//#elif defined(SIG_USART_RECV)<br />#if defined(M_USARTx_RX_vect)<br />&nbsp; // fixed by Mark Sproul this is on the 644/644p<br />&nbsp; //SIGNAL(SIG_USART_RECV)<br />&nbsp; SIGNAL(M_USARTx_RX_vect)<br />&nbsp; {<br />&nbsp; &nbsp; unsigned char c&nbsp; =&nbsp; M_UDRx;<br />&nbsp; &nbsp; store_char(c);<br />&nbsp; }<br />#endif</p><p>// Constructors ////////////////////////////////////////////////////////////////</p><p>MarlinSerial::MarlinSerial()<br />{</p><p>}</p><p>// Public Methods //////////////////////////////////////////////////////////////</p><p>void MarlinSerial::begin(long baud)<br />{<br />&nbsp; uint16_t baud_setting;<br />&nbsp; bool useU2X = true;</p><p>#if F_CPU == 16000000UL &amp;&amp; SERIAL_PORT == 0<br />&nbsp; // hardcoded exception for compatibility with the bootloader shipped<br />&nbsp; // with the Duemilanove and previous boards and the firmware on the 8U2<br />&nbsp; // on the Uno and Mega 2560.<br />&nbsp; if (baud == 57600) {<br />&nbsp; &nbsp; useU2X = false;<br />&nbsp; }<br />#endif<br />&nbsp; <br />&nbsp; if (useU2X) {<br />&nbsp; &nbsp; M_UCSRxA = 1 &lt;&lt; M_U2Xx;<br />&nbsp; &nbsp; baud_setting = (F_CPU / 4 / baud - 1) / 2;<br />&nbsp; } else {<br />&nbsp; &nbsp; M_UCSRxA = 0;<br />&nbsp; &nbsp; baud_setting = (F_CPU / 8 / baud - 1) / 2;<br />&nbsp; }</p><p>&nbsp; // assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)<br />&nbsp; M_UBRRxH = baud_setting &gt;&gt; 8;<br />&nbsp; M_UBRRxL = baud_setting;</p><p>&nbsp; sbi(M_UCSRxB, M_RXENx);<br />&nbsp; sbi(M_UCSRxB, M_TXENx);<br />&nbsp; sbi(M_UCSRxB, M_RXCIEx);<br />}</p><p>void MarlinSerial::end()<br />{<br />&nbsp; cbi(M_UCSRxB, M_RXENx);<br />&nbsp; cbi(M_UCSRxB, M_TXENx);<br />&nbsp; cbi(M_UCSRxB, M_RXCIEx);&nbsp; <br />}</p><br /><br /><p>int MarlinSerial::peek(void)<br />{<br />&nbsp; if (rx_buffer.head == rx_buffer.tail) {<br />&nbsp; &nbsp; return -1;<br />&nbsp; } else {<br />&nbsp; &nbsp; return rx_buffer.buffer[rx_buffer.tail];<br />&nbsp; }<br />}</p><p>int MarlinSerial::read(void)<br />{<br />&nbsp; // if the head isn&#039;t ahead of the tail, we don&#039;t have any characters<br />&nbsp; if (rx_buffer.head == rx_buffer.tail) {<br />&nbsp; &nbsp; return -1;<br />&nbsp; } else {<br />&nbsp; &nbsp; unsigned char c = rx_buffer.buffer[rx_buffer.tail];<br />&nbsp; &nbsp; rx_buffer.tail = (unsigned int)(rx_buffer.tail + 1) % RX_BUFFER_SIZE;<br />&nbsp; &nbsp; return c;<br />&nbsp; }<br />}</p><p>void MarlinSerial::flush()<br />{<br />&nbsp; // don&#039;t reverse this or there may be problems if the RX interrupt<br />&nbsp; // occurs after reading the value of rx_buffer_head but before writing<br />&nbsp; // the value to rx_buffer_tail; the previous value of rx_buffer_head<br />&nbsp; // may be written to rx_buffer_tail, making it appear as if the buffer<br />&nbsp; // don&#039;t reverse this or there may be problems if the RX interrupt<br />&nbsp; // occurs after reading the value of rx_buffer_head but before writing<br />&nbsp; // the value to rx_buffer_tail; the previous value of rx_buffer_head<br />&nbsp; // may be written to rx_buffer_tail, making it appear as if the buffer<br />&nbsp; // were full, not empty.<br />&nbsp; rx_buffer.head = rx_buffer.tail;<br />}</p><br /><br /><br /><p>/// imports from print.h</p><br /><br /><br /><p>void MarlinSerial::print(char c, int base)<br />{<br />&nbsp; print((long) c, base);<br />}</p><p>void MarlinSerial::print(unsigned char b, int base)<br />{<br />&nbsp; print((unsigned long) b, base);<br />}</p><p>void MarlinSerial::print(int n, int base)<br />{<br />&nbsp; print((long) n, base);<br />}</p><p>void MarlinSerial::print(unsigned int n, int base)<br />{<br />&nbsp; print((unsigned long) n, base);<br />}</p><p>void MarlinSerial::print(long n, int base)<br />{<br />&nbsp; if (base == 0) {<br />&nbsp; &nbsp; write(n);<br />&nbsp; } else if (base == 10) {<br />&nbsp; &nbsp; if (n &lt; 0) {<br />&nbsp; &nbsp; &nbsp; print(&#039;-&#039;);<br />&nbsp; &nbsp; &nbsp; n = -n;<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; printNumber(n, 10);<br />&nbsp; } else {<br />&nbsp; &nbsp; printNumber(n, base);<br />&nbsp; }<br />}</p><p>void MarlinSerial::print(unsigned long n, int base)<br />{<br />&nbsp; if (base == 0) write(n);<br />&nbsp; else printNumber(n, base);<br />}</p><p>void MarlinSerial::print(double n, int digits)<br />{<br />&nbsp; printFloat(n, digits);<br />}</p><p>void MarlinSerial::println(void)<br />{<br />&nbsp; print(&#039;\r&#039;);<br />&nbsp; print(&#039;\n&#039;);&nbsp; <br />}</p><p>void MarlinSerial::println(const String &amp;s)<br />{<br />&nbsp; print(s);<br />&nbsp; println();<br />}</p><p>void MarlinSerial::println(const char c[])<br />{<br />&nbsp; print(c);<br />&nbsp; println();<br />}</p><p>void MarlinSerial::println(char c, int base)<br />{<br />&nbsp; print(c, base);<br />&nbsp; println();<br />}</p><p>void MarlinSerial::println(unsigned char b, int base)<br />{<br />&nbsp; print(b, base);<br />&nbsp; println();<br />}</p><p>void MarlinSerial::println(int n, int base)<br />{<br />&nbsp; print(n, base);<br />&nbsp; println();<br />}</p><p>void MarlinSerial::println(unsigned int n, int base)<br />{<br />&nbsp; print(n, base);<br />&nbsp; println();<br />}</p><p>void MarlinSerial::println(long n, int base)<br />{<br />&nbsp; print(n, base);<br />&nbsp; println();<br />}</p><p>void MarlinSerial::println(unsigned long n, int base)<br />{<br />&nbsp; print(n, base);<br />&nbsp; println();<br />}</p><p>void MarlinSerial::println(double n, int digits)<br />{<br />&nbsp; print(n, digits);<br />&nbsp; println();<br />}</p><p>// Private Methods /////////////////////////////////////////////////////////////</p><p>void MarlinSerial::printNumber(unsigned long n, uint8_t base)<br />{<br />&nbsp; unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars. <br />&nbsp; unsigned long i = 0;</p><p>&nbsp; if (n == 0) {<br />&nbsp; &nbsp; print(&#039;0&#039;);<br />&nbsp; &nbsp; return;<br />&nbsp; } </p><p>&nbsp; while (n &gt; 0) {<br />&nbsp; &nbsp; buf[i++] = n % base;<br />&nbsp; &nbsp; n /= base;<br />&nbsp; }</p><p>&nbsp; for (; i &gt; 0; i--)<br />&nbsp; &nbsp; print((char) (buf[i - 1] &lt; 10 ?<br />&nbsp; &nbsp; &nbsp; &#039;0&#039; + buf[i - 1] :<br />&nbsp; &nbsp; &nbsp; &#039;A&#039; + buf[i - 1] - 10));<br />}</p><p>void MarlinSerial::printFloat(double number, uint8_t digits) <br />{ <br />&nbsp; // Handle negative numbers<br />&nbsp; if (number &lt; 0.0)<br />&nbsp; {<br />&nbsp; &nbsp; &nbsp;print(&#039;-&#039;);<br />&nbsp; &nbsp; &nbsp;number = -number;<br />&nbsp; }</p><p>&nbsp; // Round correctly so that print(1.999, 2) prints as &quot;2.00&quot;<br />&nbsp; double rounding = 0.5;<br />&nbsp; for (uint8_t i=0; i&lt;digits; ++i)<br />&nbsp; &nbsp; rounding /= 10.0;<br />&nbsp; <br />&nbsp; number += rounding;</p><p>&nbsp; // Extract the integer part of the number and print it<br />&nbsp; unsigned long int_part = (unsigned long)number;<br />&nbsp; double remainder = number - (double)int_part;<br />&nbsp; print(int_part);</p><p>&nbsp; // Print the decimal point, but only if there are digits beyond<br />&nbsp; if (digits &gt; 0)<br />&nbsp; &nbsp; print(&quot;.&quot;); </p><p>&nbsp; // Extract digits from the remainder one at a time<br />&nbsp; while (digits-- &gt; 0)<br />&nbsp; {<br />&nbsp; &nbsp; remainder *= 10.0;<br />&nbsp; &nbsp; int toPrint = int(remainder);<br />&nbsp; &nbsp; print(toPrint);<br />&nbsp; &nbsp; remainder -= toPrint; <br />&nbsp; } <br />}<br />// Preinstantiate Objects //////////////////////////////////////////////////////</p><br /><p>MarlinSerial MSerial;</p><p>#endif // whole file<br />#endif // !AT90USB</p>]]></description>
			<author><![CDATA[null@example.com (Heartlander)]]></author>
			<pubDate>Wed, 11 Sep 2013 22:18:05 +0000</pubDate>
			<guid>https://www.soliforum.com/post/35994/#p35994</guid>
		</item>
	</channel>
</rss>
