Serial ports in 64-bit Linux

I am having problems with this and have posted here:
java comm api in 64-bit Linux (second page... look for a post about the same time as this one)
Does anyone have a reliable howto for 64 bit Linux ?
Needless to say... annoyance that this is not in the core api is limitless.
Edited by: hamiljf on 06-Nov-2010 07:55

hamiljf wrote:
Needless to say... annoyance that this is not in the core api is limitless.I'm annoyed that we don't have Complex Primitives, Operator Overloading and World Peace in the core API but they ain't and are probably never going to be. If you are really annoyed then you could always switch to Mono and use System.IO.Ports . I can switch to use Mono for Operator Overloading but Mono does not have Complex Primitives or World Peace and I don't see them ever being implemented in Mono. I suppose I have to go back to FORTRAN and just forget World Peace. Bummer!

Similar Messages

  • How do I process serial port strings as bits

    In response to my commands, my instrument is sending bytes to my serial
    port. In one instance, 2 bytes are received. I want to treat these 2 bytes
    as a group of 16 bits.
    The VISA and Compatibility Serial functions return these bytes from the
    serial port to Labview clearly labelled a "string".
    Everything I can find in the way of Labview functions and .vis don't want to
    do bit twiddling, bit swapping, and bit dropping, with "string" data.
    I thought "hex string to number" could be used here, but I can't find a way.
    The 2 Bytes in question can be represented as hex, but the data are not the
    ASCII codes for the hex representation of a binary number, they are the
    binary number. This "hex string to number" seems to want ASCII c
    odes.
    You can feed a hex number typed into a "control" box wired into "hex string
    to number" and you get a meaningful number. You can feed the 2 bytes from
    the serial port into an "indicator" set to read in hex and you get a hex
    number that is a correct representation. But that is Labview handing them
    around to itself. I need to get my "hands" on them.
    I can't feed those same bytes that show up as a correct hex representation
    in an indicator into the "hex string to number" or anything else, so far,
    and get a number that is useful for further processing.
    I thought "variant to data", but I can't find enough reference material to
    understand how to use it. A boolean array seems like a bit of a weird
    approach, so I thought I'd ask before I looked into that.
    I'm used to dealing directly with binary numbers on the processor stack, I
    call them whatever I want, and turn them into anything I feel like.
    I'm sure I'm staring the solution in the face, but I can't find any way to
    persuade
    Labview to treat this "string" data as 16 bits.
    I've got the 16 bits, which is better than not having them, but I don't have
    much hair left.

    duh, well I finally discovered the "Unflatten from String" function. A guy
    just feeds in the bytes he's collected from his serial port that Labview
    thinks are a "string", and out come lovely little unsigned 16 bit numbers,
    or whatever other type of number he wants to turn the bytes into. And there
    are great little bit twiddlers available after that, like "swap bytes", and
    you can mask out bits with the logic operators, why this is fun. There's
    nothing like being a moron...... fly me to the moon...................
    "David Lewis" wrote in message
    news:[email protected]..
    > The two bytes would come from a serial port read.vi in Labview, classed as
    a
    > string. For instance, D3 and 02. The output wou
    ld swap the two bytes,
    i.e.
    > to 02 and D3, consider the two swapped bytes as 16 bits, drop the six most
    > significant bits, and output the ten bits that are left as an integer
    > classed by Labview as some kind of number, not a string.
    >
    > Your example StringToBits_Converter.vi I found on the ni.com site
    > unfortunately gives an error message and refuses to open on my system
    saying
    > it comes from a newer version of Labview 6 than I am running. Mine says
    > 6.0.1b3. Thank you very much anyway.
    >
    > "FightOnSCTrojan" wrote in message
    > news:[email protected]..
    > > In another words, you want to create a VI in which the input is 2
    > > strings (i.e. AB) and the output is the converted array bits (e.g.
    > > 1010101010101010)?
    >
    >

  • KM2M serial port not working in Linux

    I noticed a few Linux postings so I thought I'd give this a shot. I'm running Fedora Core and for some strange reason I can't seem to send any communications out to the ttyS0 (COM 1) or ttyS1 (COM 2) ports.
    Does anyone have any suggestions on making it work?
    Thank you.

    No, your code had no termination characters at all - automatic or not. The enable termination character for the VISA Configure Serial Port is only for reads. Just like the help explains.
    And while you should check the download page for updates, LabVIEW comes with the 34401 driver.
    Message Edited by Dennis Knutson on 12-19-2009 05:49 PM

  • Serial port DATABITS != 8

    Hello,
    I would like to know how Serial Port in java works. I mean, I installed the javax.comm driver in windows and there is no problem.
    However, what happens if I use 7, 6 or 5 bits of data in the serial port? The Java communicactions API provide an Outputstream to send data through serial port. So it only accepts byte [].
    If I configure my serial port with 7 bits of data, how is it sent? I mean:
    it sends only the 7 lower bits of a byte? If DATABITS are set to 5, 6, it sends the 5 or 6 lower bits of the byte?
    Thanks
    bramez

    The number of bits that is defined does not affect the byte representation in Java system. It determines only the number of bits that will represent one byte between the serial port and the device that it will be connected to it , normally external modem will be connected to serial port.
    If the number of bits = 7 , that means that the 8th. bit will be used as a parity so the Parity parameter should be Even or Odd , but if the data bits = 8, there is no parity.

  • How can I define the start bit in Serial Port Init VI?

    I don't know if the number of start bits of the Serial Port Init VI match with the serial communications requirements of the device I need to communicate with.
    Is there any way of modifying this parameter?

    LabVIEW uses the standard WindowsAPI for all of its serial functions. As such, LabVIEW does not support a customizable start bit since the native serial driver does not.

  • How can I write bits through the COM1 serial port?

    I'm trying to write bits through the serial port COM1.
    Labview "Write VI" only writes everything in string. It seems. How can I write bit by bit through COM1?
    Thank you,
    Van

    Serial transmission (COM port) protocol requires sending a group of bits at one time. You cannot just send one bit. Standard COM port settings must be either 7 or 8 data bits, 1 or 2 stop bits, etc... You have to group your bits 7 or 8 at a time. You could probably send a 0 byte or a 1 byte. This would be like sending 0000 0000 for a low bit and 0000 0001 for a high bit. Your receiving end would have to know how to interpret what you are sending if you choose this method. Of course you have to convert your byte into a string before sending to COM port. Wire a U8 data type to a Build Array input. Then wire the array output to a Byte Array to String input. The output of this function will be the character representation of your byte suitable for sending acr
    oss a serial port.
    - tbob
    Inventor of the WORM Global

  • Join two 8 bit integers and send via Serial Port

    I am trying to join two 8 bit integers and send the result via the serial port.
    I have a constant of hex value A that I need to join with a value from hex 0 - F (this is based on incoming data)
    When I use the Join VI, and type cast to change from hex to string for Visa Write, I recieve hex 0A0F.
    I have been able to use the hex 0-F with a case structure and then wire the corresponding constant ex A0 - AF.
    This makes the program very cumbersome and labour intensive to change. I have 22 commands I have to respond to with the address of 0-F.
    Currently, I have a Case structure that is selected with Message ID, then a case that is selected with subtype and then a case for address.
    Therefore I have to create a constant inside of each address case for each message as the responses are different.
    Thanks for any help
    Robin

    Gambin,
    As I understand it, you want to take the two bytes, put them together,
    and output the result as an ASCII string on the serial port.  This
    is easy.  Simply convert each number to an ASCII string,
    concatonate the two characters together, and send the resulting string
    to the VISA write function.  That's it!  I have attached a VI
    (ver. 7.1) that takes two hex numbers as input, converts them to ASCII,
    concatonates the results, and outputs the 'command' string.  Fell
    free to modify this vi and use it as you see fit.  I have left
    extra terminals in case you want to add error input/output for data
    flow, or whatever.  Notice that the display for the concatonated
    string is in '/' Codes Display mode.  This is because 0A hex is
    the newline character in ASCII.  You should also check to make
    sure that your VISA serial settings are not setup so that the newline
    character is the termination character.  If it is, the second
    character may not be recognised.  Hope this helps.
    Roy
    Attachments:
    HextoCommand.vi ‏17 KB

  • Setting Stop Bits for Serial Port

    I am using the serial communication VI (in examples/instr/smplserl.llb) to send hexidecimal commands through the serial port. I am hooked up to an oscilloscope to make sure that the commands are being sent correctly, and I have found that no matter what I set the stop bits to, I always get two stop bits. I need only one stop bit. Is there any way to fix this?

    How would I do this to my attached example? We have LabView version 6.0
    Attachments:
    SerialComm1.vi ‏45 KB

  • LV acquire the print information from the embed board with Linux system through serial port

    I want to acquire the print information by LV from the embed board with Linux system through serial port, like the window hyperterminal tool?
    I try to use VISA serial config function to achieve it ,but lost and prompt that is error like attachment.
    I can't sure that my idea is reasonable.
    help me
    thanks a lot!

    I ended up finding the answer to my problem. After pointing a client directly at one of the DPS systems, I saw the following error in the logs:
    [27/Jul/2009:17:11:47 -0400] - OPERATION  - INFO  - conn=3688 op=4 BIND RESPONSE err=12 msg="The server is not configured to pass through control 1.3.6.1.4.1.42.2.27.8.5.1" etime=0After adding that control OID to the allowed-ldap-controls, I could login via password auth. Adding this control also allowed for password changes to work from a client system.

  • Serial Ports, is it supported on MAC & Linux ??

    Hey all...
    After a long process of doing an application that runs a serial port connection to a server and upload a file to it, i could'nt find the comm package that i could download for both MAC and Linux.... There is one for Windows and Solaris though... So i was wondering, is serial ports not supported by MAC and Linux. And if not, what other than the comm package can i use to have serial ports on those 2 platforms .......
    Thanks

    Yes, there is third party support for linux and MacOS-X. It's released under GPL and can be found here -> http://www.rxtx.org/

  • [Linux] Serial Ports

    Hi,
    are the PC Com1 & Com2
    serial Ports still supported
    under LV Linux version ?
    I dont find the Serial Port VIs anymore ?
    The idea was to move a LV .vi from WinX to Linux.............
    any experiences ?

    In both Windows and Linux, you are supposed to use the VISA functions. It's almost the same, and there is a compatibility menu, with wrapper VI's that simulate the old functions. I'm currently developing an application in windows (old habbits die hard), and I'm running it under Linux without any serial problems.
    Regards,
    Wiebe.

  • Porting VIs to Linux, serial port support

    hello,
    I have installed LabVIEW 7 Express on
    Mandriva Linux
    Porting VIs Sources works well
    I had some VIs under Windows using the PC
    Serial Port, under LabVIEW 5, using the NI serpdrv file.
    Until now, unable to make run the Serial Ports
    in the Linux Version of LabVIEW....................
    any hints ?

    Hi trallala-
    Read the following KnowledgeBase articles and reply if they do not help resolve your problems.
    Troubleshooting Serial Communication in Linux
    How Do I Access The Serial Ports of My Linux Machine Without Admin Privileges?
    What Linux Distributions do National Instruments' Drivers and Software Support?
    Hope this helps!
    Drew Pierce | District Manager, Central Texas | National Instruments

  • Serial port 8 bit adc program

    I have some Pascal code writen for an 8bit Serial ADC circuit. I had a look at the Pascal code and I made an attemp at implementing it in labVIEW but obviously it didnt work. 
    The Pascal code writes/reads to the DTR, RTS and CTS lines which I was able to do with little success, I used the property node and chose 'DTR/RTS State' which gave me the options to write to the lines i mentioned above. But I am not able to read the CTS output. how can I do that in LabVIEW because LABVIEW VISA follows the RS232 protocol . I tried using the IN/Out port vi But it does not work for windows Vista & later .Can anyone help by telling me where to start from? Below is the Pascal code. I have attached my current vi which does not work.
    the circuit diagram for the 8bit adc can be found here... 
    http://www.epanorama.net/circuits/ad_serial.html
    Pascal Code........
    Program serial_adc;
    Uses Crt;
    Const
    combase=$3f8; { I/O address of the COM port you are using }
    MCR=combase+4;
    LCR=combase+3;
    MSR=combase+6;
    Procedure Initialize_converter;
    Begin
    Port[MCR]:=3; { make DTR line to supply power and set CS input of chip to 1 }
    Port[LCR]:=0; { set clock line of the chip to 0 }
    End;
    Function Read_value:byte;
    Var
    value:byte;
    count:byte;
    Begin
    value:=0;
    Port[MCR]:=1; { set CS down }
    For count:=0 to 7 Do Begin { do the bit value eading 7 times }
    value:=value SHL 1; { value=2*value }
    Port[LCR]:=64; { clock line up }
    If (port[MSR] and $10)=$10 Then Inc(value); { read the input data and update value }
    Port[LCR]:=0; { clock line down }
    End;
    Port[MCR]:=3; { set CS up again }
    Read_value:=value; { return the value }
    End;
    Begin
    Initialize_converter; { call initialization routine }
    Repeat
    Writeln(Read_value); { call reading routine and print the value }
    Delay(1200);
    Until KeyPressed; { repeat until any key is pressed }
    End.
    Attachments:
    read_In_Out_port.vi ‏24 KB
    read_from_com_port2.vi ‏40 KB

    It has been too many decades since I used Pascal to be sure what your code does.
    It seems that you are asserting DSR to provide power through the port to the external device and that you have that working.
    Are you using RTS/CTS as standard handshaking? If so, just select RTS/CTS as the value for the Flow Control input on the VISA Configure Serial Port.vi.  Then there is no need to deal with those line explicitly in the LV code.
    Note on your code: The 1 ms Wait in the sequence frame with the RTS Asserted may run before or after the property node. If you need the delay before asserting RTS, put the Wait in a frame which runs before the property node.
    If you are using USB to RS-232 adapters, verify whether the DTR line stays asserted. I have seen some adapters which think they are smarter than you are and turn off the control lines after a short idle time.
    Lynn

  • Serial Port - Linux OK, Windows No Way

    I have been trying to write to my serial port with hardware flowcontrol under windows XP all weekend. With no flow control all is well. I was about to give up on my serial port program when I decided to try my sample app under Linux Redaht 8 using the RXTX commapi. To my surprise, the code that would not work under windows worked just fine under Linux! I'm happy and confused at the same time. Here's the code snippet that processes the serial events. Does anyone have any insight into why this simple write with flow control would not work under windows XP? I have LED's connected to the serial lines and can see the CTS line doing what it's supposed to. I have administrative rights on XP. A few observations that probably mean nothing. Windows XP repors outputbuffersize=0, yet Linux returns a value. The API notes say it is advisory and may not report a value so I don't think it means anything.
    ANY help you have would be greatly appreciated.
    Thank You!
    public void serialEvent(SerialPortEvent event) {
            long timein,timeout;
              switch(event.getEventType()) {
                   case SerialPortEvent.BI:
                   case SerialPortEvent.OE:
                   case SerialPortEvent.FE:
                   case SerialPortEvent.PE:
                   case SerialPortEvent.CD:
                   case SerialPortEvent.CTS:
                        if(boolDataforWriting & event.getNewValue()){
                                  //Write data
                             timein=System.currentTimeMillis();
                             try {
    // ########## LINE THAT PRODUCES ERROR IN WINDOWS BUT NOT LINUX ###########
                                                    streamSerialOut.write(strDataForWriting.getBytes());
                             } catch (IOException e) {
                                  e.printStackTrace(); 
                             }//end catch
                             System.out.println("-->Done writing " +strDataForWriting.length()+" Bytes. Resetting str");
                                   timeout=System.currentTimeMillis();
                                   System.out.println("--->Time to write="+ (timeout-timein) + " ms");
                             //reset flags for next write operation
                             strDataForWriting="";
                             boolDataforWriting=false;
                        }//end if
                   case SerialPortEvent.DSR:
                   case SerialPortEvent.RI:
                   case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
                        break;
                   case SerialPortEvent.DATA_AVAILABLE:
                        try {
                                       byte[] readBuffer = new byte[100]; //create byte array
                                      char c;
                                      int numBytes=0;
                            while (streamSerialIn.available() > 0) {
                                     numBytes = streamSerialIn.read(readBuffer);
                                   } catch (IOException e) {}
                             break;
                                    String strtemp=(new String(readBuffer)).trim();
    }//end serialevent

    I've had this very same problem and there is a solution.
    Interestiingly I found that the same code worked on Win98 but not WinXP.
    The problem seems to lie in the JavaComm implementation. I'm guessing but your probably running with the javacomm20-win32.zip that you downloaded from Sun. I've also tried using the implementation javacom that IBM provide with there download of java1.3 and it has the same problem. So you should have a look at http://www.rxtx.org I've had success running this implementation on WinXP and Linux. To save you some time compiling there is a reasonably recent binary version at this location http://www.jcontrol.org/html/en/download.html (scroll to the bottom of the page)

  • Problem communicating via serial port in Linux

    Hello,
    I am trying to transfer data via serial port, in Linux.
    But it is impossible till now!
    I get Runtime exception.
    Here is my code:
    public class Main {
        public Main() {
        int num=5;
        int[] array = new int[5];
        public static void main(String args[])  {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    array[0]=1;
                    array[1]=2;
                    array[2]=3;
                    array[3]=4;
                    array[4]=5;
                    new ParallelCommunication(num,array);
    import java.io.*;
    import java.util.*;
    import javax.comm.*; // for SUN's serial/parallel port libraries
    //import gnu.io.*; // for rxtxSerial library
    public class ParallelCommunication implements Runnable, SerialPortEventListener {
       static CommPortIdentifier portId;
       static CommPortIdentifier saveportId;
       static Enumeration portList;
       InputStream inputStream;
       SerialPort serialPort;
       Thread readThread;
       static OutputStream outputStream;
       static boolean outputBufferEmptyFlag = false;
       int num;
       int[] array;
       public ParallelCommunication(int this_num,int[] this_array) {
          boolean portFound = false;
          String defaultPort;
          num = this_num;
         array=new int[this_array.length];     
          array = this_array;     
          // determine the name of the serial port on several operating systems
          String osname = System.getProperty("os.name","").toLowerCase();
          if ( osname.startsWith("windows") ) {
             // windows
             defaultPort = "COM1";
          } else if (osname.startsWith("linux")) {
             // linux
            defaultPort = "/dev/ttyS0";
          } else {
             System.out.println("Sorry, your operating system is not supported");
             return;
    //      if (args.length > 0) {
    //         defaultPort = args[0];
          System.out.println("Set default port to "+defaultPort);
          // parse ports and if the default port is found, initialized the reader
          portList = CommPortIdentifier.getPortIdentifiers();
          while (portList.hasMoreElements()) {
             portId = (CommPortIdentifier) portList.nextElement();
             if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
                if (portId.getName().equals(defaultPort)) {
                   System.out.println("Found port: "+defaultPort);
                   portFound = true;
                   // init reader thread              
                   initialize();
                   break;
          if (!portFound) {
             System.out.println("port " + defaultPort + " not found.");
       public void initwritetoport() {
          // initwritetoport() assumes that the port has already been opened and
          //    initialized by "public void initialize()"
          try {
             // get the outputstream
             outputStream = serialPort.getOutputStream();
          } catch (IOException e) {}
          try {
             // activate the OUTPUT_BUFFER_EMPTY notifier
             serialPort.notifyOnOutputEmpty(true);
          } catch (Exception e) {
             System.out.println("Error setting event notification");
             System.out.println(e.toString());
             System.exit(-1);
       public void writetoport(int counter) {
          try {
             // write string to serial port
             outputStream.write(String.valueOf(array[counter]).getBytes());
          } catch (IOException e) {}
       public void initialize() {
          // initalize serial port
          try {
             serialPort = (SerialPort) portId.open("SimpleReadApp", 2000);
          } catch (PortInUseException e) {System.out.println("Port In Use.");}  //******Here is the Exception******
          try {
             inputStream = serialPort.getInputStream();
          } catch (IOException e) {}
          try {
             serialPort.addEventListener(this);
          } catch (TooManyListenersException e) {}
          // activate the DATA_AVAILABLE notifier
          serialPort.notifyOnDataAvailable(true);
          try {
             // set port parameters
             serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8,
                         SerialPort.STOPBITS_1,
                         SerialPort.PARITY_NONE);
          } catch (UnsupportedCommOperationException e) {}
          // start the read thread
          readThread = new Thread(this);
          readThread.start();
       public void run() {
          // first thing in the thread, we initialize the write operation
         initwritetoport();     
         for(int i=0; i<=num_of_inputs; i++) {
            // write string to port, the serialEvent will read it
            writetoport(i);
         serialPort.close();     
       public void serialEvent(SerialPortEvent event) {
          switch (event.getEventType()) {
          case SerialPortEvent.BI:
          case SerialPortEvent.OE:
          case SerialPortEvent.FE:
          case SerialPortEvent.PE:
          case SerialPortEvent.CD:
          case SerialPortEvent.CTS:
          case SerialPortEvent.DSR:
          case SerialPortEvent.RI:
          case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
             break;
          case SerialPortEvent.DATA_AVAILABLE:
             // we get here if data has been received
             byte[] readBuffer = new byte[20];
             try {
                // read data
                while (inputStream.available() > 0) {
                   int numBytes = inputStream.read(readBuffer);
                // print data
                String result  = new String(readBuffer);
                System.out.println("Read: "+result);
             } catch (IOException e) {}
             break;
    }...and the outcome is :
    Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException:
    Error opening "/dev/ttyS0"
    tcgetattr(): Input/output error
    at com.sun.comm.LinuxDriver.getCommPort(LinuxDriver.java:66)
    at javax.comm.CommPortIdentifier.open(CommPortIdentifier.java:369)
    at ParallelCommunication.initialize(ParallelCommunication.java:128)
    I have searched a lot and I couldn't find a solution.
    Thank you.

    I'm having the same problem this helped somewhat debug the problem
    http://bloggerdigest.blogspot.com/2006/11/linux-serial-com-port-diagnostic-test.html
    I'm running Suse 10.3 and apparently it does not recognize my serial ports. So before
    you can test your Java code you have to figure out how to make linux see the ports.
    If I find a solution I'll let you know but if you find one first let me know. Thanks.

Maybe you are looking for

  • Effects dialog no longer shows up!

    My iPhoto has the following problem... when I'm looking at a picture, full screen or not the effects dialog doesn't come up if I click on it. Any ideas? Thanks in advance!

  • BOTH of my K210 Systems have the very same problem

    Hope somebody can help.   I have two identical Lenovo IdeaCenter K210 machines.   They were shut off for a trip away from home for holiday. BOTH machines are failing to start in the same exact way.    Push power on button,  chasis fan, cpu fan, power

  • Will Apple replace NVIDIA graphics card for free?

    I've read a lot of discussions on here about the failing NVIDIA cards and Apple having to replace the entire motherboard. Some users have had the experience of Apple replacing the card free of charge, others have had to pay a hefty price. Is there an

  • When I try to backup catalog to DVD only a few of the pictures come through

    When I try to gackup catalog on photoshop to a DVD only a few pictures come through.  Seems to take a really long time.

  • I just can't solve this Photoshop graphic problem

    Greetings... I've seen a bit hereabouts on graphics import problems, but nothing so far has led me to a solution. Here's the thing: A multi-layer graphic was created for me in Photoshop CS2. It has a backround image and text. I intend to use it as a