Writing 7 data bits/even parity over sockets

Hi, I'm having trouble finding information on this topic, even though several threads out there allude to the subject so hopefully someone can clarify this for me...take a simple case: I need to send a byte over a socket formatted as 7bits/even parity, say for example the character 4. So in ASCII this has the binary representation 00110100, I flip the parity bit to make it even and we get 10110100. But Java doesn't support unsigned chars and thus will not let me create a byte > 127. I've tried to send it as an int (180), short, hex(b4) but the conversions don't seem to address the underlying problem; most of the solutions posted to similar problems involved the next step up ie. 16bit short but doesn't this send a high byte and a low byte out over the socket which will be interpreted by the gateway expecting 8-bit unsigned bytes as 2 individual bytes?
- Craig

It turned out to be the wrong value once I coded it. The code for that and the correct one is below.
byte b1 = (byte)(256 - '4');
System.out.println("wrong b=" + (int)b1);
System.out.println("wrong b=" + Integer.toHexString(b1));
byte b2 = (byte)Integer.parseInt("1111111110110100", 2);
System.out.println("right b=" + (int)b2);
System.out.println("right b=" + Integer.toHexString(b2));

Similar Messages

  • 7 Data Bits, Even Parity, 1 Stop Bit over IP

    Hello,
    I have a service provider that required ALL transmission even over IP to be 7 Data Bits, Even Parity, 1 Stop Bit. Is this even possible?
    I have been going around and around with this dude. 7E1 is serial communications not IP communications right? Maybe I am wrong...
    Regards,
    -Jeff

    Hello,
    I have a service provider that required ALL
    transmission even over IP to be 7 Data Bits, Even
    Parity, 1 Stop Bit. Is this even possible?
    It is not possible. What you are talking about is serial protocol with involves more than 8 bits. A stop bit is used to frame the other bits and would lie outside the 8 bit boundary.
    Section 1.2 in the following works well enough in explaining this....
    http://www.freebsd.org/doc/en_US.ISO8859-1/articles/serial-uart/
    Although unlikely it is possible that the provider actually does require an encoded serial protocol (stop bit required.) If that is the case then the service provider needs to provide the specific encoding that they need. However I suspect that they don't require the stop bit. It is quite possible that they require the even parity however.
    I have been going around and around with this dude.
    7E1 is serial communications not IP communications
    right? Maybe I am wrong...That statement is probably incorrect presuming that in fact the actual word size is 8 bits. You use 7 bits for data. You then compute the eighth bit such that the bits in the word (all 8) are even. You can use a 128 size array to do a simple look up for this.
    IP of course takes 8 bits so this is no problem. The character set would be a 7 bit character set like ascii.

  • How do you set the number of rows in a spreadsheet, so that even when you drag data in, in writes over those rows instead of adding a new row?

    How do you set the number of rows you want in a spreadsheet, so that even when you drag data in, in writes over those rows instead of adding a new row?

    After the discovery reported above, I filed this report :
    Bug ID# 10073038
    Summary:
    When Numbers is used on a system with decimal comma a csv file may be good AND wrong
    Steps to Reproduce:
    With Numbers v2, you introduced an interesting enhancement.
    In system using the comma as decimal separator, Numbers requires csv files using the semi-colon as values delimiter.
    In fact it’s true if we OPEN the document dragging its icon on Numbers one or thru the open dialog.
    This said.
    (1) Drag and drop a csv built with the 'semi-colon' standard on a table or on a sheet
    (2) Drag and drop a csv built with the 'comma' standard on a table or on a sheet
    Expected Results:
    Every normally constituted user assume that in
    case (1) he will get a perfectly built table
    case (2) he will get every cells of a row in a single cell
    Actual Results:
    In fact you forgot the drag and drop way of use and in
    case (1) every values separated by semi-colon are inserted in a single cell
    case (2) values separated by comma are correctly spread in a table
    isn’t it ridiculous ?
    Regression:
    Except looking in  QuickView to see which is exactly the structure of the file to decide the way we will insert it in a Numbers document, we may use an applescript fair enough to replace the semi-colons by TAB characters
    or
    to replace the commas by TABs and the decimal periods by commas
    Notes:
    While I am on this subject, I wish to make two proposals:
    (1)  It would be fine to format the date according to the ISO format year-mm-dd when you export a Numbers doc to csv.
    Doing that, dates would be imported correctly in every countries.
    At this time, on an English system, you export as mm/dd/year.
    If the doc is open on a system using the format dd/mm/year, the results will be odd.
    On a system using the format dd/mm/year, you export this way and so, if the doc is open on a system using the format mm/dd/year the results are odd too.
    As every localized versions accept the ISO format (at least on entry), using it in the export scheme would give a correct behavior everywhere.
    (2) It would be fine to add the format Tab Separated Values in the Export pane.
    TSV + ISO date format would give documents opening flawlessly everywhere.
    Yvan KOENIG (VALLAURIS, France) dimanche 4 septembre 2011 21:27:41
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0
    My iDisk is : <http://public.me.com/koenigyvan>
    Please : Search for questions similar to your own before submitting them to the community

  • Binary file transfert over socket : data corupted !

    Hi everyone,
    I am trying to transfert binary files over Socket (java.net) and I get corrupted data... I know the data I write in the Socket is ok and I wonder why I don't get it right at the end.
    Does anyone know about it ?

    Ok i have re-written it without the Packet class and it know works...
    I give my code in case someone would be interested.
    ENCODER :
    public class Encoder {
         // the file to send
         private File file;
          * Constructor of the Encoder class
          * @param path the path to the file to send
         public Encoder(String path){
              this.file = new File(path);
              this.encodeFile();
          * This method contains the connection an file tranfert code
         private void encodeFile(){
              try {
                   // opening file reading stream
                   FileInputStream fis = new FileInputStream(this.file);
                   // connection...
                   Socket sock = new Socket("127.0.0.1", 5698);
                   // opening an output stream
                   BufferedOutputStream bos = new BufferedOutputStream(sock.getOutputStream(), 1024);
                   // start time
                   long start = System.currentTimeMillis();
                   // setting up the buffer
                   byte[] buffer = new byte[1024];
                   /* ---- File Transfert Loop ---- */
                   // reading for the first time
                   int read = fis.read(buffer);
                   while (read > 0){
                        bos.write(buffer);
                        bos.flush();
                        read = fis.read(buffer);
                   /* ----End Of File Transfert ---- */
                   // end time
                   long end = System.currentTimeMillis();
                   // closing streams and connection
                   fis.close();
                   bos.close();
                   sock.close();
                   // display file transfert duration
                   System.out.println("Completed in :" + (end - start) + " ms !");
              } catch (IOException e) {
                   e.printStackTrace();
    DECODER :
    public class Decoder {
         private File destFile;
         public Decoder(String path){
              try {
                   // setting up destination file
                   this.destFile = new File(path);
                   // setting up file writting stream
                   FileOutputStream fos = new FileOutputStream(this.destFile);
                   // setting up connection server
                   ServerSocket serv = new ServerSocket(5698);
                   // accepting client connection request
                   Socket sock = serv.accept();
                   // setting up reading stream for the connection
                   BufferedInputStream bis = new BufferedInputStream(sock.getInputStream());
                   // setting up byte buffer
                   byte[] buffer = new byte[1024];
                   // first reading
                   int read = bis.read(buffer);
                   while (read != -1){
                        // writting buffer content into file
                        for (int i=0; i < read; i++){
                             fos.write(buffer);
                        // reading next bytes
                        read = bis.read(buffer);
                   //closing streams
                   fos.close();
                   bis.close();
              } catch (IOException e) {
                   e.printStackTrace();

  • Synchronizing peers in transfer over Socket

    Hi again!
    I'm relatively new to Java, so there are many issues I still have to figure out ;-)
    Here are two of them:
    1) How can peers be synchronized in transfer over Socket? For example:
    This is the receiving peer:
    DataInputStream dsin = new DataInputStream(socket.getInputStream());
    String s = dsin.readUTF();This is the sending peer:
    DataOutputStream dsout = new DataOutputStream(socket.getOutputStream());
    dsout.writeUTF("something...");
    dsout.close();At the receiving peer in some cases the EOFException or SocketException (Socket closed) are raised. I suspect this happens either because the receiver tries to read input before it is fully transfered or when the sender already managed to close the socket's OutputStream.
    So how can such a transfer be synchronized?
    2) What if both peers close their socket's OutputStream? Does this result in closing the connection and releasing all its resources, such as port?
    Thank you everyone!

    this is what I learnt:Sorry, try again!
    DO NOT close the Socket on any endpoint until you make sure that the other endpoint managed to call socket.getInputStream().This 'rule' is quite unnecessary.
    According to the documentation, getInputStream() may return a stream which buffer was discarded by network software if a broken connection was detected.That's a complete misreading and misquoting of the documentation. A reset can happen to the connection at any time; can cause loss of data from te socket receive buffer; and has nothing to do with the operation of getting the input stream. Getting the input stream of a socket has nothing to do with the network or the state of the connection. It just constructs a Java object. So this rule is quite pointless.
    Even more, it seems to be a good practice not to close the Socket until you are sure that the other endpoint will not try to read from the channel.You've got that back to front as well. THink about that some more and you will see it involves an infinite regression.
    The only rules you need are these:
    (a) don't close the socket until you're sure the other end has finished writing. You have to close the socket while the other end is still reading, so that it will get a EOS indication, so it will know you've gone away, so it will stop writing and close its end of the socket.
    (b) closing the socket or either of its streams closes the other two items. You should always close the topmost output stream of a socket and nothing else.

  • Reading an Even Parity Byte Stream

    I'm using a socket connection and, strangely enough, the data is being sent with an even parity byte.  This means there are 7 data bits and 1 parity bit.
    If you haven't guessed by now, this means that both socket.readByte() and readUnsignedByte() both fail me, as that left most bit is actually just the parity setting.
    So, I know that in c i could just trim the final bit with something like:
    char letter = dataByte & 0x7F;
    How on earth do I get my 7 bit ASCII decimal out of this byte in actionscript?
    I thought maybe I could read it into a ByteArray and trim the unneeded bit, but honestly I'm grasping at straws here.

    The issue I was having was that ActionScript has no way to read parity bits. So, when it saw 10101100 (44 with even parity bit flipped), it read that as -84. Now that may seem strange, as it did to me, so you'll want to read all about it on Wikipedia.
    Now, to fix this strange issue, we simply need to be sure that if the parity bit is flipped to 1, we flip it back to zero. Doing this is simple, because ActionScript reads the parity bit as a negative byte.
    var text:String = "";
    var tmp:int = socket.readByte();
    var charCode:int code;
    if(tmp < 0)  //check to see if the parity bit was flipped to 1
         code=tmp & 0x7F;  //reset the parity bit to 0
    else
         code=tmp;  //nothing to do if parity bit is 0
    text+=String.fromCharCode(code);
    Now, should ActionScript support the reading of parity bits?  I doubt that is in the cards.  Still, good to know that if you do find them they are easy to deal with.

  • Serialization over sockets

    Hi All!
    So i've decided to perform serialization over sockets - so i made a server that has an ObjectOutputStream and a client that has ObjectInputStream and i wrote a Properties object.
    I managed to get passed the EOFException problem and the same object writing problem (using reset()), but i've read that this isn't efficient, and on top it all it has the problem of blocking.
    I've read some posts regarding Serialization and NIO but i couldn't get from them what i should do - so can someone plz explain to me:
    1) How can i write objects to sockets using NIO
    2) Furthermore - if this really solves the memory and efficiency problems
    3) A code sample or a ref. would really be appriciated.
    Regards,
    Snayit

    Basically I would ask myself if I really need NIO - for MOST purposes the old-blocking IO is very good and much easier to use.
    One of the biggest problems with blocking IO is, that for thousands of clients you need an own thread which causes many OSes to truggle.
    I really recommend buffering the streams! (Via BufferedInput/OutputStream) but do not forget to flush() them if you really want the data to be sent.
    If you want to use NIO you have to write the object-data into a byte-array (creating a bytearrayoutputstream -> ObjectOutputStream) and writing this byte-arrays.
    hope this helps, lg Clemens

  • "Error 13 writing data in step 6: type mismatch" - Error during package run

    Hi experts,
    I am using SAP BPC 7.0 M and facing an issue while importing a package. I am encountering the error : "Error 13 writing data in step 6: type mismatch". The package is running successfully for some files but is failing for similar other files. The data is uploading successfully on server but still it is giving an error while conversion.
    Thanks,
    Regards,
    Kamya Nagpal

    Hi All,
    In continuation to the above message:
    Even when the package is failing, the data is getting uploaded in the server.
    Thanks,
    Regards,
    Kamya Nagpal
    Infosys Technologies Limited

  • I am writing datas into a FIFO ,i am reading datas from fifo .but when i am writing datas like a a(0),a(1),a(2 like that.when i am reading dating datas a(0)comes to a(3 ) rd place .what is the reason ?

    I am writing datas into a FIFO in FPGA Target side  ,i am reading datas from fifo in windows host side  .but when i am writing datas like a a(0),a(1),a(2 like that.when i am reading dating datas a(0)comes to a(3 ) rd place, a(1) comes to a a(0) .what is the reason ?

    Please use a shorter title in your subject line and not post the entire question in therre.  (See the subject line I created.)   There is also no such word as "datas".  Data is already plural.
    Please read http://stackoverflow.com/help/how-to-ask.  Your question is hard to read because you aren't using proper punctuation and capitalization of your sentences.  It looks like one run-on sentence.
    Beyond that, it is impossible to help you solve our problem with just your question.  Please provide some more information.  Perhaps even attach code we can look at.  Show us what the data you are sending is supposed to look like, and what it actually looks like.

  • Send XML over Sockets

    I am beginning and I need to send XML formatted data from Swing Client to Server for parsing/processing/and response.
    There are no web server available to use. I think its best to use socket connection, but how do I send xml data over socket, and how do I receive it from server and parse it?
    I have read and cannot find a similar example.

    Xerces has DOMSerializer which can be used to serialize a Document object to a string. Once it's a string it's trivial to transmit over a socket connection. On the other side, to parse it, you'll have to create a StringReader for the received string and then an InputSource from the StringReader. You'll then be able to pass the InputSource to the DocumentBuilder.parse( ) method to generate a Document on the receiving side.
    Hope that helps,
    - Jesse

  • Filetransfer over sockets

    hi,
    im currently working on a filetransfer over sockets. this is what i do:
    i have a connection from the client to the server. on both sides i have a PrintStream for the output and a bufferedReader to read the responses. the client asks for a file and the server answers with the md5-hash size of the file, so that the client knows how many bytes it has to read. that works fine.
    now the filetransfer:
    the server writes the bytes of the file directly to the OutputStream (not the PrintStream). the client opens a BufferedInputStream on the mentioned socket and reads in as many bytes, as the server said before.
    now the problem:
    sometimes the filetransfer works fine, but sometimes some bytes are missing. i wonder where they are gone. it cant be a problem with the flush() method, because im using OutputStream to send the data. (i tested BufferedOutputStream with flush() with the same results).
    maybe it's not working because a attached a BufferedReader and a BufferedInputStream to the InputStream on the client-side...
    does anybody know, whats going wrong?
    let me know if you want to see some code.
    greetings,
    henrik

    i have solved this problem by using java.nio

  • 9i can't connect to a data base, even when I use another user's tnanames.or

    I can't connect to a data base, even using tnsping with a tnanames.ora file that I copied from a user's PC that was able to connect. It's a new install of 9i on my PC. What did I miss? I'm on a Win 2000 box and Oracle is on a UNIX server.
    Here's the description from the tnsnames.ora file:
    HISTA02A =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = bkodv1)(PORT = 1521))
    (CONNECT_DATA =
    (SERVICE_NAME = HISTA02)
    The file is from the previous version 8.1.7, should that matter? 9.2.0.1 is the server now.

    Yes, I even pinged it to make sure. When I do a tnsping HISTA02 I get :
    C:\>tnsping HISTA02
    TNS Ping Utility for 32-bit Windows: Version 9.2.0.1.0 - Production on 28-FEB-2007 14:25:53
    Copyright (c) 1997 Oracle Corporation. All rights reserved.
    Used parameter files:
    C:\Local\network\ADMIN\sqlnet.ora
    TNS-03505: Failed to resolve name
    My SQLNT.ora looks like this:
    # SQLNET.ORA Network Configuration File: C:\orant\network\admin\sqlnet.ora
    # Generated by Oracle configuration tools.
    NAMES.DEFAULT_DOMAIN = cboent.cboe.com
    SQLNET.AUTHENTICATION_SERVICES= (NTS)
    NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME)

  • My iPhone 4S register 3G data traffic even if all the app are closed

    My iPhone 4S registers 3G data traffic even if all the apps are closed: whenever I'm not under wi-fi I see the 3G icon lighted up whenever I go trough set icon, or calendar or message device...even if all these utilities doesn't require 3G data. If I just check mobile data consumption I see it increasing of few KB per time.
    I don't have neither push notifications nor location on, just I don't understand this phenomenon.
    Please...forgive me for my English...I'm writing from Italy and it's not so easy to explain what I'm talking about.

    I got...but whenever I open the setting icon, I see 3G becoming lit up and colored and..if I check "mobile data consumption" I can find out that this figure increases each time I check it...just going out and into again this section of the settings. Each time I send a message via SMS I see 3G icon colored and lit up again...even if I'm not using any data connection!!!!To avoid the problem I shut down mobile data conncetion when I don't need it and when I'm not under wi-fi...so I can't tell how much is the 3G traffic data generated during one day.
    Just I wanted to understand if there's a different method to avoid it...

  • Problem while writing data on xls file using jxl API

    Hi,
    I am getting problem while writing data on excel file using jxl api.
    When i write data on file and all handles associated to the file are closed, file size increases but when i open the file nothing is written in it and when file is closed manually from excel window, file size decreased to its original that was before writing data.
    here is code:
              FileOutputStream os = new FileOutputStream(this.dirPath + this.fileName, true);
              WritableWorkbook this.workbook = Workbook.createWorkbook(os);
    after writing data following handler are closed:
    this.os.flush();
                        this.workbook.write();
                        this.workbook.close();
                        this.os.close();
                        this.os = null;
    can any body help me.
    Thanks in advance

    Err, I did help you. I did understand your problem; and I solved it for you. What was missing was that you apparently made no effort to understand what you were being told. Or even consider it. You just argued about it, as though you were the one with the solution, instead of the one whose code didn't work.
    And the other thing that was missing was the part where you said 'thank you' to me for solving your problem. Somewhat more appropriate than biting the hand that fed you, frankly. I do this for nothing, on my own gas, and it's extremely irritating when people keep asking about problems I have already solved for them. I am entitled to discourage that. It's part of making them more efficient actually.
    But it happens often enough that it also makes me think I'm just wasting my time. Probably I am.

  • Writing data to spreadsheet in FOR loop without shift register

    My program has a case window within a For loop.  The loop iteration index is wired to the case, so there’s a case for each iteration of the loop (about 30 cases).  In each case, data points are gathered, formatted to a spreadsheet and written to a file, along with some occasional header strings to describe the data.  This works fine, as I can simply write the data to file as soon as I get it. 
    At some point in the loop, I’m gathering from two sources (rpm data for two fans) over several iterations that is to be written to two separate but similar formatted tables in the same output file.  Since I’m writing two tables to one file simultaneously, I can no longer write on-the-fly in a linear fashion; I’d need to store all the information until I complete the iterations, then format the header & raw data to spreadsheet and write to file in two chunks – at least, this is what I believe is the way to go, but I’m all ears if there’s another way.
    In order to buffer the data, I could use a shift register, but this requires me to wire an array across my loop for all loops, whether I’ll be using it or not.  I’ve also considered initializing an array at the case I’ll need to start buffering, then writing to a local variable of that array, but in fiddling with this approach, I don’t see how to specify what index to which I’m storing the data point.
    So I’m looking for advice on whether (1) there’s another way to accomplish my goal and/or (2) how to execute the initialize array and local variable approach. 
    Below is a picture of what I want this portion of the spreadsheet to look like.  Also included is a much abbreviated mock-up of my program for a case where I’m writing on the fly for a single table or column of information and a case where I’m setting up the write to local variable approach.  
    Message Edited by TESTIE on 04-03-2008 12:48 PM
    Attachments:
    illustration22.JPG ‏52 KB
    output_file2.JPG ‏120 KB
    illustration3.JPG ‏50 KB

    An Action Engine can thought of as an encapsulated shift register.
    AE's out-perform locals while alos elliminating possible race conditions. You may want to review the Nugget I wrote on Action Engines.
    Just trying to help,
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

Maybe you are looking for

  • Help whit open file!!!!!Urgent

    hi i have 1 great problen whit my servlet. I use Fop class for create pdf file from xml and class work very well, but i need translate this class in a servlet class and when open file on the fly in browser size of this is equals a 0kb why? this is ma

  • Windows 8 MAIL client renames G-Mail PDF attachments filename and extension to PDF????

    Hi PPL, I have the Windows 8 MAIL client configured to get G-Mail based on an imap configuration. When opening gmail.com in Internet Explorer and looking at a specific email I do see 2 attachments for example with name: "Mail Attachement1.PDF" &  "Ma

  • Orchestration takes more than 30 mins to open

    Hi all We have BizTalk 2013 Server, and our development enviroment is Visual Studio 2013. Any time a new Orchestration is added to the Project. It takes more than 30 mins to open the Orchestration What could be the issue here? Thanks in Advance for y

  • Regarding URL Connection Creation.

    Hi, I am trying to create a URL Connection in JDev 11.1.2, and using the following JDev RSS URL: http://www.oracle.com/ocom/groups/public/@otn/documents/webcontent/132361.xml However, when I am testing the connection, its saying "Specified URL Connec

  • R3 to CRM - user not getting transferred

    Hi, Please give inputs for this error u2013 u201CUser not transferred from R3 to CRMu201D Even little guidance will help me. Regards, Arnab