         // Command Mode -----------------------------------------------------------------------
         if (Modem_isCommandMode)
         {
+            unsigned char unsignedInbound;
+            boolean isValid = true;
+            char temp[5];
+            
             if (Modem_flowControl) 
                 digitalWriteFast(C64_CTS, LOW);
             //char inbound = toupper(_serial->read());
             char inbound = C64Serial.read();
 
-            if (Modem_EchoOn)
+            // Block non-ASCII/PETSCII characters
+            unsignedInbound = (unsigned char)inbound;
+            if (unsignedInbound == 0x08 || unsignedInbound == 0x0a || unsignedInbound == 0x0d) {}  // backspace, LF, CR
+            else if (unsignedInbound <= 0x1f)
+                isValid = false;
+            else if (unsignedInbound >= 0x80 && unsignedInbound <= 0xc0)
+                isValid = false;
+            else if (unsignedInbound >= 0xdb)
+                isValid = false;
+
+            /*
+            if (!isValid) {
+                sprintf(temp, "-%d-",unsignedInbound);
+                C64Serial.write(temp);
+            }*/
+
+            if (Modem_EchoOn && isValid)
             {
                 if (!Modem_flowControl) 
                 delay(100 / (BAUD_RATE / 2400));     // Slow down command mode to prevent garbage if flow control

                    Modem_CommandBuffer[strlen(Modem_CommandBuffer) - 1] = '\0';
                }
            }
            else if (inbound != '\r' && inbound != '\n' && inbound != Modem_S2_EscapeCharacter)
            {
                if (strlen(Modem_CommandBuffer) >= COMMAND_BUFFER_SIZE) {
                  //Display (F("CMD Buf Overflow"));

    return result;
}

void DisplayPhoneBook() {
    for (int i = 0; i < ADDR_HOST_ENTRIES; i++)
    {
        C64Serial.print(i+1);
        C64Print(F(":"));
        C64Println(readEEPROMPhoneBook(ADDR_HOSTS + (i * ADDR_HOST_SIZE)));
    }
    C64Println();
#ifdef HAYES    
    C64Print(F("Autostart: "));
    C64Serial.print(EEPROM.read(ADDR_HOST_AUTO));
    C64Println();
#endif
}

void Modem_Dialout(char* host)
{
    char* index;
    uint16_t port = 23;
    String hostname = String(host);

        if (strlen(host) == 0)
        {
#ifdef HAYES
            Modem_PrintERROR();
#endif
            return;
        }
    
        if ((index = strstr(host, ":")) != NULL)
        {
            index[0] = '\0';
            hostname = String(host);
            port = atoi(index + 1);
        }
    /*if (hostname == F("5551212"))
    {
        QuantumLinkReloaded();
        return;
    }*/

    lastHost = hostname;
    lastPort = port;

    Connect(hostname, port, false);
}

