Forum > Linux
Use tts0, This example is from chatgpt,but why it doesn't work?
coradi:
This example is from chatgpt,but why it doesn't work?
With hterm the LED from CH UART is working, but with this code, nothing happends
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program uart19200; {$mode objfpc}{$H+} uses cthreads, SysUtils, synaser; var Serial: TBlockSerial; ReceivedData: string;begin // WriteLn('Empfangene Daten: '); // Serielle Schnittstelle initialisieren Serial := TBlockSerial.Create; try // Serielle Schnittstelle öffnenModify message
Jurassic Pork:
hello,
i don't see in your code init of the serial port.
Friendly, J.P
Thaddy:
You need to ask the question more precise:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program SerialPortListener; {$mode objfpc}{$H+} uses cthreads, SysUtils, synaser; var Serial: TBlockSerial; ReceivedData: string; begin // Initialize the serial port Serial := TBlockSerial.Create; try // Set the device to the appropriate serial port (e.g., /dev/ttyS0 or /dev/ttyUSB0) Serial.Connect('/dev/ttyS0'); // Set the baud rate to 19200, 8 data bits, no parity, 1 stop bit Serial.Config(19200, 8, 'N', SB1, False, False); // Loop to read data from the serial port while True do begin // Check if data is available if Serial.CanRead(1000) then begin // Read the data ReceivedData := Serial.RecvPacket(1000); // Print the received data WriteLn('Received: ', ReceivedData); end; end; finally // Clean up Serial.Free; end;end.Not my code, chatGPT :D :D This one works if the synapse library is in the path or the package is installed. (just tested, minimally on /dev/ttyUSB0, the above code is untouched)
Both synaser examples from the wiki also work when you set up the config for your conection:
https://wiki.freepascal.org/Hardware_Access#Serial_Communication
coradi:
same..nothing happens
No blinking RX LED or something.
With Hterm it works well
I use /dev/ttyUSB0
cdbc:
Hi
Just checking...
You are trying to fit Thaddy's example to use your local values, right?!?
...Not just copy-pasting and hoping... ;D
Regards Benny
Navigation
[0] Message Index
[#] Next page