Benoît Minisini schreef: >> mike wrote: >> >>> I'm having trouble with Gambas and the serial ports. >>> Something is changing binary &h0d to &h0a when received >>> from a serial port. I noticed it in a program that I've >>> been working on that receives packets of binary data >>> from a microprocessor. I wrote a little test program to >>> demonstrate the problem and have included it below. I also >>> reprogrammed the micro to simply send &h0d as long a >>> pushbutton is held depressed. I have verified that the >>> correct data is indeed being sent using CuteCom to display >>> the binary data. >>> An interesting thing that I noticed when I ran CuteCom to >>> test the data being received is that if I close CuteCom without >>> closing the serial port first then run my Gambas program, it works >>> fine until I restart the system. If I close the port before closing >>> CuteCom then my Gambas program fails. >>> >>> >>> This is the code for the test program. >>> >>> ' Gambas class file >>> ' Using Gambas 2.18 on a system running >>> ' Fedora Kernel (26.30.9-102.fc11.x86_64) >>> ' It also fails running Gambas 2.11 >>> ' on my laptop running >>> ' Fedora Kernel (2.6.27.25-78.2.56.fc9.i686) >>> >>> PUBLIC SUB Form_Open() >>> >>> ME.Center >>> >>> ' Setup the serial port - 9600,8,N,1 >>> >>> ' SerPort1.PortName = "/dev/ttyS0" ' Both ports fail >>> SerPort1.PortName = "/dev/ttyUSB0" ' This the port I'll eventually >>> use SerPort1.Speed = "9600" ' because the laptop has no >>> serial port. >>> SerPort1.DataBits = "8" >>> SerPort1.Parity = "0" >>> SerPort1.StopBits = "1" >>> SerPort1.Open >>> >>> TextArea1.Text = SerPort1.PortName & Chr$(10) >>> END >>> >>> PUBLIC SUB SerPort1_Read() >>> >>> ' A microprocessor is connected to the serial port and >>> ' continuously sends &h0d (CR) as long a push button is held down. >>> >>> DIM InByte AS Byte >>> >>> READ #SerPort1, InByte >>> TextArea1.Insert(Hex$(InByte) & " ") >>> ' The textarea displays a series of "A " (LF) instead of "D " (CR) >>> END >>> >>> PUBLIC SUB ExitBtn_Click() >>> >>> SerPort1.Close >>> QUIT >>> END >>> >>> PUBLIC SUB ClearBtn_Click() >>> >>> TextArea1.Clear >>> END >>> >> This is a Linux thing. Not Gambas. The icrnl flaf is set as standard. >> Easiest way is to use stty to change it. >> >> SHELL "stty -F " & SerPort1.PortName & " -icrnl" >> >> > > I'm not a serial port user at all, and I find that behaviour a bit strange. > >
Me too. I have build serial support for about 10 different hardware devices in my Gambas project both binary and ASCII and didn't stumble upon this strange behavior (yet?) Regards, Ron_2nd. ------------------------------------------------------------------------------ Return on Information: Google Enterprise Search pays you back Get the facts. http://p.sf.net/sfu/google-dev2dev _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user