I jsut posted with a lot less information a problem I am having and did not get a reply. So now I will post all the information I have available and hope for some help here.
My problem involves trim methods serialports and file streams. my on recevied method reads the first line and should parse it out to give me a file name. In my case the first line has 2 extra characters i have to remove plus two more characters added in the transfer from the okuma lathe machines we use. So I strip the extra chars to make a good file name then add them back so the file is correct. I then read the rest of the port buffers data and add it to a string. Take the two strings write them to the file.writealltext method and I should have a file. The string.length is comeing back as being 61 chars long so I tried triming it a few different ways none have worked. Included I have an example .min file which is an instruction for the machine I am sending to, the out put I get from the console and my code. The output from the file.WriteallTExt method when viewed in notepad ++ reveals a slew of trailing nulnulnulnul chars which I dont know how to recreate here so. Here it is in a nutshell, any help will be greatly appreciated.
#region
using
#endregion
namespace
{
str = str.Substring(3);
str = str.TrimEnd(
str = str.Trim();
}
SERCOM.Handshake =
SERCOM.BaudRate = 600;
SERCOM.DataBits = 7;
SERCOM.StopBits =
SERCOM.PortName = args[2].ToString();
SERCOM.Parity =
SERCOM.DtrEnable =
SERCOM.RtsEnable =
SERCOM.DataReceived +=
SERCOM.Encoding =
SERCOM.Open();
lotr.Close();
SERCOM.WriteLine(lotrS);
SERCOM.Close();
};
____________ console out put
C:\WINDOWS>O:\PC\"Com Com Deploy.exe" 1 0 COM9Waiting to receive file from LathePress any key to quit, without transfering? $M-15637.MIN64sub M-15637.MIN61M-15637.MINpost trim 61 M-15637.MIN
end
_this correlates to my on received which is in a testing faze to figure out why it wasint working I was testing lengths and you can see how trim and trimend both keep the same string.length _
__________ example file *correct looking*
$M-16136.MIN%ZZ=-.XXXTH=.140 (USE .005 OR LESS ID TOOL RADIUS)CO=.XXXFP=00FS=.0000SP=00SS=.0000TP=00TS=.0000DP=00DS=.0000CA=[TH+CO+.005]CS=[TH+CO+.010]G50 S2500NSTRTVZSHZ=0VZSHX=0V20=0V1=3/IF[VDIN[24]EQ 1]NBAR/CALL OFEED/GOTO N01 /NBAR CALL ONBARN01 G00 X.850 Z.100 TXXXX S2000 M3 (FACE TOOL)N02 G01 Z.005 F.010N03 G01 X-.100N05 G00 X20 Z1.0N06 G00 X.559 Z.050 TXXXX M08 (PLUNGE)N07 G01 Z0 F.006N08 G76 G01 X.383 L-.025 N09 G01 Z-.105 F.004N10 G91 G01 X+.015 N11 G90 G01 X.383 N12 G91 G01 X-.015 N13 G90 G01 X.383 F.006N14 G76 G01 Z-.008 L-.025N15 G01 X.208N16 G00 Z.1N17 G00 X20 Z1.0N18 G00 X.230 Z.050 TXXXX (ID ROUGHING)N19 G01 Z-CA F.005N20 G00 Z.1N21 G00 X.282 Z.050 TXXXXXX (ID)N22 G41 G01 Z-.008 F.005N23 G01 X.258 Z-.028 F.004N24 G01 X.267 Z-.078N25 G01 X.276N26 G01 X.282 Z-.105N27 G01 Z-TH+.017N28 G02 X.316 Z-TH L.017N29 G40 G01 Z-CA F.007N30 G01 X.230 F.010N31 G00 Z.1N32 G00 X20 Z1.0 M09N33 G00 X.485 Z.050 TXXXXXX (OD)N34 G42 G01 Z0 F.005N00 G03 X.509 Z-.0525 L.120 F.004N35 G03 X.485 Z-.105 L.120 N36 G01 Z-TH+.017N37 G03 X.451 Z-TH L.017N38 G40 G01 Z-CA F.005N39 G01 X.559 F.010N40 G01 Z-CA-.020 A-45N41 G00 Z.1N42 G00 X20 Z1.0N43 G00 X.559 Z.100 TXXXX (CO)N44 G00 Z-TH-CON45 G01 X.228 F.004N46 G01 X.559 F.010N00 G01 Z.100N47 G00 X20 Z1.0N48 /VZSHZ=VZSHZ-CSV20=V20+1IF[VZSHZ-CS+ZZ LE VNVLZ-VZOFZ] N100IF[V20 EQ FP]N200IF[V20 EQ SP]N210IF[V20 EQ TP]N220IF[V20 EQ DP]N230GOTO N01N200VZSHX=VZSHX+FSGOTO N01N210VZSHX=VZSHX+SSGOTO N01N220VZSHX=VZSHX+TSGOTO N01N230VZSHX=VZSHX+DSGOTO N01N100 VZSHZ=0G00 X30 Z30M05 TXXXX S700GOTO NSTRTM30 %