Serial.write documentation errors.
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 38/100
- Issue-Typ
- Dokumentation
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- arduino
- Bereich
- documentation, embedded-iot
Rechercherichtung
Öffne die verlinkte Serial.write-Referenz und vergleiche deren Parameterbeispiele mit dem Verhalten bei einem Argument, das der Processing-Sketch und die Arduino-Ausgabe zeigen. Aktualisiere die Referenz, sodass unterstützte Signaturen und das Verhalten des niederwertigsten Bytes korrekt sind, und überprüfe anschließend, dass die Beispiele keine Aufrufe mit mehreren Parametern mehr nahelegen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Description
- The reference for Serial.write implies that you can have one or more parameters of type byte[], String or int. As far as I can see it accepts only one parameter (of any of those types).
The method write(int) in the type Serial is not applicable for the arguments (String, int)
The method write(int) in the type Serial is not applicable for the arguments (int, String)
- Serial.write with integer parameter sends only the least-significant byte.
Assuming that serial.write(int-var) is valid, although not an example in Processing-4 (it was an example in Processing-3). It sends only the least-sig byte. Maybe this is as intended, but the reference doesn't say that so you'd expect the whole integer, all 4 bytes, to be written.
Expected Behavior
I'd expect the serial.write() to accept all the formats given in the reference. Assuming that the code is working correctly, then the reference should have examples of each possibility write(byte[]), byte, String, int. (I've only tested int.) No examples with multiple parameters.
I'd expect write(int) to send the whole integer, or if the help states that it only sends the least-sig byte, then 1 byte will do.
Current Behavior
Serial.write does not accept the reference multi-parameter examples.
The method write(int) in the type Serial is not applicable for the arguments (int, String)
The method write(int) in the type Serial is not applicable for the arguments (String, int)
Serial.write(int) sends only the least-sig byte.
Steps to Reproduce
Processing code.
- Comment in lines 28,29 and they are not accepted.
- Sends int to Ard at 1Hz. Prints out the returned text.) You can see that Ard is getting only the least sig-byte.
final boolean T = true;
final boolean F = false;
import processing.serial.*;
Serial port;
byte b1;
int i1 = 0;
long l1;
void setup() {
frameRate(10);
size(140, 80);
port = new Serial(this, "COM13", 9600);
noStroke();
smooth();
}
void draw() {
boolean inComing = F;
char ch;
if (frameCount > 50 && frameCount % 10 == 0) {
b1 = (byte) i1;
l1 = i1;
//port.write(i1, "");
//port.write("", i1);
port.write(i1);
print(String.format("X %d ",l1));
i1 += 53;
}
if (port.available() > 0) {print("R "); inComing = T; delay(10);}
while (port.available() > 0)
{
ch = (char) port.read();
print(ch);
}
if (inComing) {print(" "); inComing = F;}
}
Arduino Code
#define pM pinMode
#define dW digitalWrite
int i1;
int led = 7;
void setup()
{
Serial.begin(9600);
Serial.println();
Serial.println(__FILE__);
Serial.println(__DATE__);
Serial.println(__TIME__);
pM(led, OUTPUT);
}
void loop()
{
dW(led, 0);
if (Serial.available() > 0) {
i1 = Serial.read();
dW(led, 1);
Serial.print(i1);
}
delay(10);
}
Output:
X 0 R 0 X 53 R 53 X 106 R 106 X 159 R 159 X 212 R 212 X 265 R 9
X 318 R 62 X 371 R 115 X 424 R 168 X 477 R 221 X 530 R 18
X 583 R 71 X 636 R 124 X 689 R 177 X 742 R 230 X 795 R 27
X 848 R 80 X 901 R 133
X is the value Processing has, continues increasing. Arduino is sending back value of only 1 byte, limited to 255.
Your Environment
Windows-10, Processing 4.0b3, Ard 1.8.5, Ard-Nano.
Possible Causes / Solutions
Which is right, the serial.write() behaviour, or the reference? Why was the documentation changed between Processing 3 and 4. The easy solution is to make the reference match the current behaviour. Only 1 parameter of 3 types.
For the write(int) add the reference line, something like "with an integer parameter the least-significant byte is sent (value 0..255).
- Vorherrschende Sprache
- MDX
- Sterne
- 90
- Forks
- 122
- Ø Merge
- 1 Std. 20 Min.
- Gemergte PRs (30 T.)
- 4
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus processing/processing-website
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
processing/processing-website#716 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
processing/processing-website#703 ·
-
Good First Issue Help Wanted Reference
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
processing/processing-website#698 · 5 Kommentare · 1 Reaktion ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 72/100
processing/processing-website#681 · 2 Kommentare ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
processing/processing-website#646 · 3 Kommentare ·
Alle Issues in processing/processing-website
Ähnliche Issues
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Mintplex-Labs/anything-llm#6490 ·
-
bug needs response
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Adyen/adyen-dotnet-api-library#1869 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
w3c/webdriver-bidi#1168 ·
-
area/documentation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
rancher/fleet-product-docs#393 ·
-
Type/Improvement
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 90/100
OpenNSW/nsw-srilanka#522 ·