I'm stuck. I try to open a serial Port on Linux using Pharo.
The code is as simple as:
port := SerialPort new.
portName := '/dev/ttyUSB0'.
port openPort: portName.
Now this opening fails for "whatever" reason.
Anyway in the console I got the following "messages":
PluggableTextMorph>>handleEdit: in Block: [result := editBlock value]
Error while opening the serial port (/dev/ttyUSB0#4
).
Error: Cannot open '/dev/ttyUSB0'
It seems after the USB0 there is not the "end" of the string but some
gibberish.
I tried to extract the code for the SerialPlugin and use it stand-alone
in C andwrote the following:
#include <stdio.h>
#include "SerialPlugin.h"
int main(void) {
char *portName = "/dev/ttyUSB0";
int baudRate = 9600;
int stopBitsType = 1;
int parityType = 0;
int dataBits = 8;
int inFlowControlType = 0;
int outFlowControlType = 0;
int xOnByte = 19;
int xOffByte = 24;
int iRval;
iRval = serialPortOpenByName (portName,
baudRate, stopBitsType, parityType,
dataBits, inFlowControlType, outFlowControlType,
xOnByte, xOffByte);
iRval = serialPortCloseByName (portName);
return 0;
}
And there is no error while using it this way in C. So what
is broken?
Regards
Friedrich