Applescript Read Serial Port

To read single byte from serial device. Data = ser.read to read given number of bytes from the serial device. Data = ser.read(size=5) to read one line from serial device. Data = ser.readline to read the data from serial device while something is being written over it. Diablo 2 patch 1.13.

Do you know the printer is working properly?You are trying to fix more than one thing at once and that's never a good idea. What I suggest you do is get a breadboard and make your own printer simulator. You need to connect and LED up to every output pin and a button to every input pin.Then you can simulate data from the printer, i.e. Just pressing the button for pin 3 and you should see 1 coming out on the serial monitor. OK I agree this 'simulator' is rubbish, but you probably have the bits to knock it up now.If you are still seeing 'junk' values then have a look and see if there is a pattern to the data. This would be helped by printing the values in hex.Of course if the Arduino side works then the issue is that the printer is sending data that you are not expecting. It might help stick LEDs on every pin, both directions, it will help you see what is being sent.Its possible that you are expecting 1 to indicate the bit is set and the printer is using 0.

Some C# code to read a serial port. Using this as a starting point for an Arduino project.
ReadSerialPort.cs
usingSystem;
usingSystem.IO.Ports;
namespaceSerialReader
{
classProgram
{
staticvoidMain(string[] args)
{
varreader=newArduinoSerialReader('COM3');
Console.ReadLine();
}
staticvoidListComPorts()
{
// Get a list of serial port names.
string[] ports=SerialPort.GetPortNames();
Console.WriteLine('The following serial ports were found:');
// Display each port name to the console.
foreach (stringportinports)
{
Console.WriteLine(port);
}
}
}
publicclassArduinoSerialReader : IDisposable
{
privateSerialPort_serialPort;
publicArduinoSerialReader(stringportName)
{
_serialPort=newSerialPort(portName);
_serialPort.Open();
_serialPort.DataReceived+=serialPort_DataReceived;
}
voidserialPort_DataReceived(objects, SerialDataReceivedEventArgse)
{
Console.WriteLine(_serialPort.ReadLine());
}
publicvoidDispose()
{
if (_serialPort!=null)
{
_serialPort.Dispose();
}
}
}
}

commented May 4, 2018

thanks bro

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment