<p>The line defining <code>SERIAL_PORT</code> in <code>MarlinSerial.h</code> should read:</p>

<pre><code>#define SERIAL_PORT 0
</code></pre>

<p>To [mis-]quote <a href="https://reprap.org/forum/read.php?415,830189,830193#msg-830193" rel="nofollow noreferrer">this answer</a> from RepRap:<a href="https://reprap.org/forum/read.php?415,830189" rel="nofollow noreferrer">'rx_buffer' was not declared in this scope</a> (the emphasis is mine):</p>

<blockquote>
<pre><code>#define SERIAL_PORT 4
</code></pre>
  
  <p>This is the serial port on the controller, not the serial port on your
  computer. 0 through 3 are valid options on a controller with a atmel
  2560. </p>
  
  <p>Unless you are doing something like serial over bluetooth or
  deliberately not using the USB port <strong><em>you should not change this from 0</em></strong></p>
</blockquote>

<p>The same error is reported on the Arduino forums, <a href="https://forum.arduino.cc/index.php?topic=561571.0" rel="nofollow noreferrer">'rx_buffer' was not declared in this scope</a>:</p>

<blockquote>
  <p>Have redone over 5 times and always getting " 'rx_buffer' was not
  declared in this scope ".</p>
  
  <p>Now I tried Factory marlin and same "
  'rx_buffer' was not declared in this scope " . Dont know what to do - I'm
  so lost.</p>
  
  <p>...</p>

<pre><code>#define SERIAL_PORT 4     //before was 0
</code></pre>
  
  <p>Nothing else</p>
</blockquote>

CC BY-SA 4.0
2019-04-19T21:11:19.753Z
2019-04-19T21:11:19.753Z
Greenonline
<p>After one successful preview of compile, the upload returns error </p>

<pre><code>rx_buffer not defined in this scope. 
</code></pre>

<p>How do I fix this?</p>

CC BY-SA 4.0
2019-05-07T05:21:04.307Z
Have you found and fixed the problem? If so, has the answer below led you to the solution? Please vote to accept the answer so this question is not bumped up once in a while and can be removed from the unanswered question list. You may even add your own solution and accept that after 48 hours! If you have not been able to address the problem please update your question.
Greenonline
CC BY-SA 4.0
2019-04-19T14:22:53.993Z
Have you changed `#define SERIAL_PORT 0` in MarlinSerial.h?
0scar
<marlin>
Marlin error Rx_buffer not declared in scope
Steve Weems
# Marlin error Rx_buffer not declared in scope

(Asked by: username_0 on 2019-04-19)

After one successful preview of compile, the upload returns error

```
rx_buffer not defined in this scope. 

```

How do I fix this?

**Tags:** marlin

> **Comments:**
> **username_2**: Have you changed `#define SERIAL_PORT 0` in MarlinSerial.h?  
> **username_1**: Have you found and fixed the problem? If so, has the answer below led you to the solution? Please vote to accept the answer so this question is not bumped up once in a while and can be removed from the unanswered question list. You may even add your own solution and accept that after 48 hours! If you have not been able to address the problem please update your question.  

---

## 1 answers

### Answer by username_1 on 2019-04-19. Score: 1

The line defining `SERIAL_PORT` in `MarlinSerial.h` should read:

```
#define SERIAL_PORT 0

```

To [mis-]quote [this answer](https://reprap.org/forum/read.php?415,830189,830193#msg-830193) from RepRap:['rx\_buffer' was not declared in this scope](https://reprap.org/forum/read.php?415,830189) (the emphasis is mine):

> ```
> #define SERIAL_PORT 4
>
> ```
>
> This is the serial port on the controller, not the serial port on your
> computer. 0 through 3 are valid options on a controller with a atmel
> 2560.
>
> Unless you are doing something like serial over bluetooth or
> deliberately not using the USB port ***you should not change this from 0***

The same error is reported on the Arduino forums, ['rx\_buffer' was not declared in this scope](https://forum.arduino.cc/index.php?topic=561571.0):

> Have redone over 5 times and always getting " 'rx\_buffer' was not
> declared in this scope ".
>
> Now I tried Factory marlin and same "
> 'rx\_buffer' was not declared in this scope " . Dont know what to do - I'm
> so lost.
>
> ...
>
> ```
> #define SERIAL_PORT 4     //before was 0
>
> ```
>
> Nothing else


---

